checklists_controller_policy.rb 674 B

1234567891011121314151617181920212223242526272829303132333435
  1. # Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/
  2. class Controllers::ChecklistsControllerPolicy < Controllers::ApplicationControllerPolicy
  3. def create?
  4. Setting.get('checklist') && Pundit.authorize(user, ticket, :agent_update_access?)
  5. end
  6. def update?
  7. ChecklistPolicy
  8. .new(user, checklist)
  9. .update?
  10. end
  11. def destroy?
  12. ChecklistPolicy
  13. .new(user, checklist)
  14. .destroy?
  15. end
  16. def show?
  17. ChecklistPolicy
  18. .new(user, checklist)
  19. .show?
  20. end
  21. private
  22. def checklist
  23. Checklist.lookup(id: record.params[:id])
  24. end
  25. def ticket
  26. Ticket.lookup(id: record.params[:ticket_id])
  27. end
  28. end