From e55e509493dbde22357a35c766359fcd3913514f Mon Sep 17 00:00:00 2001 From: Matthew Landauer Date: Tue, 10 Sep 2024 23:57:50 +0000 Subject: [PATCH] Add scraper editor role --- app/models/user.rb | 2 +- app/policies/admin/applications_policy.rb | 6 +++--- app/policies/admin/authority_policy.rb | 12 ++++++------ 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/app/models/user.rb b/app/models/user.rb index 6ada9ad48..6472cf381 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -39,7 +39,7 @@ def send_devise_notification(notification, *args) sig { returns(T::Boolean) } def can_login_to_admin? - has_role?(:admin) || has_role?(:api_editor) + has_role?(:admin) || has_role?(:api_editor) || has_role?(:scraper_editor) end # This is currently used when creating users via an alert diff --git a/app/policies/admin/applications_policy.rb b/app/policies/admin/applications_policy.rb index ea9c1d35a..70e3644cf 100644 --- a/app/policies/admin/applications_policy.rb +++ b/app/policies/admin/applications_policy.rb @@ -7,12 +7,12 @@ class ApplicationsPolicy < ApplicationPolicy sig { returns(T::Boolean) } def index? - user.has_role?(:admin) + user.has_role?(:admin) || user.has_role?(:scraper_editor) end sig { returns(T::Boolean) } def show? - user.has_role?(:admin) + user.has_role?(:admin) || user.has_role?(:scraper_editor) end sig { returns(T::Boolean) } @@ -23,7 +23,7 @@ def destroy? class Scope < ApplicationPolicy::Scope sig { returns(ActiveRecord::Relation) } def resolve - user.has_role?(:admin) ? scope.all : scope.none + user.has_role?(:admin) || user.has_role?(:scraper_editor) ? scope.all : scope.none end end end diff --git a/app/policies/admin/authority_policy.rb b/app/policies/admin/authority_policy.rb index 7a51eb074..654ee0a1a 100644 --- a/app/policies/admin/authority_policy.rb +++ b/app/policies/admin/authority_policy.rb @@ -7,33 +7,33 @@ class AuthorityPolicy < ApplicationPolicy sig { returns(T::Boolean) } def create? - user.has_role?(:admin) + user.has_role?(:admin) || user.has_role?(:scraper_editor) end sig { returns(T::Boolean) } def index? - user.has_role?(:admin) + user.has_role?(:admin) || user.has_role?(:scraper_editor) end sig { returns(T::Boolean) } def show? - user.has_role?(:admin) + user.has_role?(:admin) || user.has_role?(:scraper_editor) end sig { returns(T::Boolean) } def update? - user.has_role?(:admin) + user.has_role?(:admin) || user.has_role?(:scraper_editor) end sig { returns(T::Boolean) } def import? - user.has_role?(:admin) + user.has_role?(:admin) || user.has_role?(:scraper_editor) end class Scope < ApplicationPolicy::Scope sig { returns(ActiveRecord::Relation) } def resolve - user.has_role?(:admin) ? scope.all : scope.none + user.has_role?(:admin) || user.has_role?(:scraper_editor) ? scope.all : scope.none end end end