account_warning_policy.rb 310 B

1234567891011121314151617
  1. # frozen_string_literal: true
  2. class AccountWarningPolicy < ApplicationPolicy
  3. def show?
  4. target? || role.can?(:manage_appeals)
  5. end
  6. def appeal?
  7. target? && record.created_at >= Appeal::MAX_STRIKE_AGE.ago
  8. end
  9. private
  10. def target?
  11. record.target_account_id == current_account&.id
  12. end
  13. end