checklists_controller_policy.rb 732 B

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