Our domain of "admin?" method names is already a bit confounding. The policy methods renamed the existing Policy::Authorizer methods, and further obfuscated and confused intention. This refactor aligns the policy methods with the Policy::Authorizer methods. It is a non-breaking change, but one that may add warnings in the logs. If you see those, resolve them per instructions. Related to #16483
19 lines
350 B
Ruby
19 lines
350 B
Ruby
class DiscussionLockPolicy < ApplicationPolicy
|
|
PERMITTED_ATTRIBUTES = %i[article_id notes reason].freeze
|
|
|
|
def create?
|
|
(user_author? || user_any_admin?) && !user_suspended?
|
|
end
|
|
|
|
alias destroy? create?
|
|
|
|
def permitted_attributes
|
|
PERMITTED_ATTRIBUTES
|
|
end
|
|
|
|
private
|
|
|
|
def user_author?
|
|
record.locking_user_id == user.id
|
|
end
|
|
end
|