status_policy.rb 776 B

1234567891011121314151617181920212223242526272829303132333435
  1. # frozen_string_literal: true
  2. class Admin::StatusPolicy < ApplicationPolicy
  3. def initialize(current_account, record, preloaded_relations = {})
  4. super(current_account, record)
  5. @preloaded_relations = preloaded_relations
  6. end
  7. def index?
  8. role.can?(:manage_reports, :manage_users)
  9. end
  10. def show?
  11. role.can?(:manage_reports, :manage_users) && (record.public_visibility? || record.unlisted_visibility? || record.reported? || viewable_through_normal_policy?)
  12. end
  13. def destroy?
  14. role.can?(:manage_reports)
  15. end
  16. def update?
  17. role.can?(:manage_reports)
  18. end
  19. def review?
  20. role.can?(:manage_taxonomies)
  21. end
  22. private
  23. def viewable_through_normal_policy?
  24. StatusPolicy.new(current_account, record, @preloaded_relations).show?
  25. end
  26. end