Skip to content

Commit

Permalink
Add scraper editor role
Browse files Browse the repository at this point in the history
  • Loading branch information
mlandauer committed Sep 10, 2024
1 parent 62dc1e3 commit e55e509
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion app/models/user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions app/policies/admin/applications_policy.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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) }
Expand All @@ -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
Expand Down
12 changes: 6 additions & 6 deletions app/policies/admin/authority_policy.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit e55e509

Please sign in to comment.