pundit: convert tags to pundit.
This commit is contained in:
@@ -210,7 +210,7 @@ class Tag < ApplicationRecord
|
||||
# next few lines if the category is changed.
|
||||
tag.update_category_cache
|
||||
|
||||
if tag.editable_by?(creator)
|
||||
if Pundit.policy!([creator, nil], tag).can_change_category?
|
||||
tag.update(category: category_id)
|
||||
end
|
||||
end
|
||||
@@ -382,13 +382,6 @@ class Tag < ApplicationRecord
|
||||
cosplay_tags.grep(/\A(.+)_\(cosplay\)\Z/) { "#{TagAlias.to_aliased([$1]).first}_(cosplay)" } + other_tags
|
||||
end
|
||||
|
||||
def editable_by?(user)
|
||||
return true if user.is_admin?
|
||||
return true if !is_locked? && user.is_builder? && post_count < 1_000
|
||||
return true if !is_locked? && user.is_member? && post_count < 50
|
||||
return false
|
||||
end
|
||||
|
||||
def posts
|
||||
Post.tag_match(name)
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user