checklist_items_controller_policy.rb 728 B

12345678910111213141516171819202122232425262728293031323334353637
  1. # Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/
  2. class Controllers::ChecklistItemsControllerPolicy < Controllers::ApplicationControllerPolicy
  3. def create?
  4. Checklist::ItemPolicy
  5. .new(user, checklist&.items&.build)
  6. .create?
  7. end
  8. def show?
  9. Checklist::ItemPolicy
  10. .new(user, checklist_item)
  11. .show?
  12. end
  13. def update?
  14. Checklist::ItemPolicy
  15. .new(user, checklist_item)
  16. .update?
  17. end
  18. def destroy?
  19. Checklist::ItemPolicy
  20. .new(user, checklist_item)
  21. .destroy?
  22. end
  23. private
  24. def checklist
  25. Checklist.lookup(id: record.params[:checklist_id])
  26. end
  27. def checklist_item
  28. Checklist::Item.lookup(id: record.params[:id])
  29. end
  30. end