This commit is contained in:
Toks
2013-04-29 17:40:29 -04:00
parent e1c34df22e
commit 78281a9b4c
3 changed files with 6 additions and 2 deletions

View File

@@ -35,6 +35,6 @@ class TagsController < ApplicationController
private private
def check_privilege(tag) 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
end end

View File

@@ -561,6 +561,10 @@ class Tag < ActiveRecord::Base
end end
end end
def editable_by?(user)
user.is_builder? || (user.is_member? && post_count <= 50)
end
include ApiMethods include ApiMethods
include CountMethods include CountMethods
extend ViewCountMethods extend ViewCountMethods

View File

@@ -18,7 +18,7 @@
<%= link_to(tag.name, posts_path(:tags => tag.name)) %> <%= link_to(tag.name, posts_path(:tags => tag.name)) %>
</td> </td>
<td> <td>
<% if CurrentUser.is_builder? || tag.post_count <= 50 %> <% if tag.editable_by?(CurrentUser.user) %>
<%= link_to "edit", edit_tag_path(tag) %> <%= link_to "edit", edit_tag_path(tag) %>
<% end %> <% end %>
<% if CurrentUser.is_builder? && tag.post_count < 1_000 %> <% if CurrentUser.is_builder? && tag.post_count < 1_000 %>