Skip to content

Commit

Permalink
Update policies to use team where possible
Browse files Browse the repository at this point in the history
This updates the policies to filter the objects on the teams directly
rather than from the programme, which is removing the concept of
programmes being attached to teams.
  • Loading branch information
thomasleese committed Sep 27, 2024
1 parent f6c07d9 commit 85e7298
Show file tree
Hide file tree
Showing 7 changed files with 9 additions and 9 deletions.
6 changes: 3 additions & 3 deletions app/policies/batch_policy.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ def initialize(user, scope)
end

def resolve
@scope.joins(vaccine: { programmes: :team }).where(
teams: {
id: @user.teams.ids
@scope.joins(vaccine: :programmes).where(
programmes: {
team: @user.teams
}
)
end
Expand Down
2 changes: 1 addition & 1 deletion app/policies/consent_form_policy.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ def initialize(user, scope)
end

def resolve
@scope.joins(:programme).where(programme: { team_id: @user.teams.ids })
@scope.joins(:session).where(session: { team: @user.teams })
end
end
end
2 changes: 1 addition & 1 deletion app/policies/consent_policy.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ def initialize(user, scope)
end

def resolve
@scope.joins(:programme).where(programme: { team_id: @user.teams.ids })
@scope.joins(:programme).where(programme: { team: @user.teams })
end
end
end
2 changes: 1 addition & 1 deletion app/policies/patient_session_policy.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ def initialize(user, scope)
end

def resolve
@scope.joins(:session).where(session: { team_id: @user.teams.ids })
@scope.joins(:session).where(session: { team: @user.teams })
end
end
end
2 changes: 1 addition & 1 deletion app/policies/session_policy.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ def initialize(user, scope)
end

def resolve
@scope.where(team_id: @user.teams.ids)
@scope.where(team: @user.teams)
end
end
end
2 changes: 1 addition & 1 deletion app/policies/vaccination_record_policy.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ def initialize(user, scope)
end

def resolve
@scope.joins(:programme).where(programme: { team_id: @user.teams.ids })
@scope.joins(:session).where(session: { team: @user.teams })
end
end
end
2 changes: 1 addition & 1 deletion app/policies/vaccine_policy.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ def initialize(user, scope)
end

def resolve
@scope.joins(:programmes).where(programmes: { team_id: @user.teams.ids })
@scope.joins(:programmes).where(programmes: { team: @user.teams })
end
end
end

0 comments on commit 85e7298

Please sign in to comment.