diff --git a/app/controllers/tags_controller.rb b/app/controllers/tags_controller.rb index efe200273..32f0bbaed 100644 --- a/app/controllers/tags_controller.rb +++ b/app/controllers/tags_controller.rb @@ -35,6 +35,6 @@ class TagsController < ApplicationController private def check_privilege(tag) - raise User::PrivilegeError unless (CurrentUser.is_builder? || tag.post_count <= 50) + raise User::PrivilegeError unless tag.editable_by?(CurrentUser.user) end end diff --git a/app/models/tag.rb b/app/models/tag.rb index 1e8944d83..347f4a35a 100644 --- a/app/models/tag.rb +++ b/app/models/tag.rb @@ -561,6 +561,10 @@ class Tag < ActiveRecord::Base end end + def editable_by?(user) + user.is_builder? || (user.is_member? && post_count <= 50) + end + include ApiMethods include CountMethods extend ViewCountMethods diff --git a/app/views/tags/index.html.erb b/app/views/tags/index.html.erb index 2e47cddae..5f4eae7d7 100644 --- a/app/views/tags/index.html.erb +++ b/app/views/tags/index.html.erb @@ -18,7 +18,7 @@ <%= link_to(tag.name, posts_path(:tags => tag.name)) %> - <% if CurrentUser.is_builder? || tag.post_count <= 50 %> + <% if tag.editable_by?(CurrentUser.user) %> <%= link_to "edit", edit_tag_path(tag) %> <% end %> <% if CurrentUser.is_builder? && tag.post_count < 1_000 %>