trabajo-afectivo/app/policies/knowledge_base/answer_policy.rb

41 lines
677 B
Ruby
Raw Normal View History

2022-01-01 13:38:12 +00:00
# Copyright (C) 2012-2022 Zammad Foundation, https://zammad-foundation.org/
class KnowledgeBase::AnswerPolicy < ApplicationPolicy
def show?
return true if access_editor?
record.visible? ||
(access_reader? && record.visible_internally?)
end
def show_public?
access_editor? || record.visible?
end
def create?
access_editor?
end
def update?
access_editor?
end
def destroy?
access_editor?
end
private
def access
@access ||= KnowledgeBase::EffectivePermission.new(user, record.category).access_effective
end
def access_editor?
access == 'editor'
end
def access_reader?
access == 'reader'
end
end