2022-10-26 13:42:29 +02:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
class Admin::StatusPolicy < ApplicationPolicy
|
|
|
|
def initialize(current_account, record, preloaded_relations = {})
|
|
|
|
super(current_account, record)
|
|
|
|
|
|
|
|
@preloaded_relations = preloaded_relations
|
|
|
|
end
|
|
|
|
|
|
|
|
def index?
|
|
|
|
role.can?(:manage_reports, :manage_users)
|
|
|
|
end
|
|
|
|
|
|
|
|
def show?
|
2025-01-07 02:47:58 -05:00
|
|
|
role.can?(:manage_reports, :manage_users) && eligible_to_show?
|
2022-10-26 13:42:29 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
def destroy?
|
|
|
|
role.can?(:manage_reports)
|
|
|
|
end
|
|
|
|
|
|
|
|
def update?
|
|
|
|
role.can?(:manage_reports)
|
|
|
|
end
|
|
|
|
|
|
|
|
def review?
|
|
|
|
role.can?(:manage_taxonomies)
|
|
|
|
end
|
2023-09-06 16:40:19 +02:00
|
|
|
|
|
|
|
private
|
|
|
|
|
2025-01-07 02:47:58 -05:00
|
|
|
def eligible_to_show?
|
|
|
|
record.distributable? || record.reported? || viewable_through_normal_policy?
|
|
|
|
end
|
|
|
|
|
2023-09-06 16:40:19 +02:00
|
|
|
def viewable_through_normal_policy?
|
|
|
|
StatusPolicy.new(current_account, record, @preloaded_relations).show?
|
|
|
|
end
|
2022-10-26 13:42:29 +02:00
|
|
|
end
|