pundit: convert tags to pundit.

This commit is contained in:
evazion
2020-03-17 17:35:59 -05:00
parent 4cd0b2cbfe
commit 4bb036aff1
6 changed files with 27 additions and 31 deletions

View File

@@ -0,0 +1,15 @@
class TagPolicy < ApplicationPolicy
def can_change_category?
user.is_admin? ||
(user.is_builder? && !record.is_locked? && record.post_count < 1_000) ||
(user.is_member? && !record.is_locked? && record.post_count < 50)
end
def can_lock?
user.is_moderator?
end
def permitted_attributes
[(:category if can_change_category?), (:is_locked if can_lock?)].compact
end
end