Tags: don't allow deprecation of tags without wiki
This commit is contained in:
@@ -8,13 +8,14 @@ class TagPolicy < ApplicationPolicy
|
||||
end
|
||||
|
||||
def can_change_deprecated_status?
|
||||
return false if record.wiki_page.blank? && !record.is_deprecated?
|
||||
user.is_admin? || (record.post_count == 0 && !record.is_deprecated?)
|
||||
end
|
||||
|
||||
def permitted_attributes
|
||||
[
|
||||
(:category if can_change_category?),
|
||||
(:is_deprecated if can_change_deprecated_status?),
|
||||
].compact
|
||||
permitted = []
|
||||
permitted << :category if can_change_category?
|
||||
permitted << :is_deprecated if can_change_deprecated_status?
|
||||
permitted
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user