Skip to content

Commit

Permalink
remove unneeded policies and scope
Browse files Browse the repository at this point in the history
  • Loading branch information
ahamelers committed Aug 14, 2024
1 parent 0def39a commit 0a05ae5
Showing 1 changed file with 2 additions and 35 deletions.
37 changes: 2 additions & 35 deletions app/policies/stash_engine/admin_datasets_policy.rb
Original file line number Diff line number Diff line change
@@ -1,20 +1,12 @@
module StashEngine
class AdminDatasetsPolicy < ApplicationPolicy

def index?
@user.min_admin?
end

def activity_log?
index?
end

def stats_popup?
index?
@user.min_admin?
end

def note_popup?
index?
@user.min_admin?
end

def data_popup?
Expand All @@ -33,30 +25,5 @@ def waiver_add?
@user.superuser?
end

class Scope
def initialize(user, scope, params)
@user = user
@scope = scope
@params = params
end

def resolve
if @user.tenant_limited?
@scope.where(**@params, tenant: @user.tenant)
elsif @user.min_app_admin?
@scope.where(**@params)
elsif @user.journals_as_admin.present?
@scope.where(**@params, journals: @user.journals_as_admin.map(&:title))
elsif @user.funders.present?
@scope.where(**@params, funders: @user.funders.map(&:ror_id))
else
false
end
end

private

attr_reader :user, :scope
end
end
end

0 comments on commit 0a05ae5

Please sign in to comment.