Browse Source

Add parent schemes to the user model directly

pull/2237/head
Kat 2 years ago
parent
commit
b8ebe21624
  1. 2
      app/jobs/scheme_email_csv_job.rb
  2. 2
      app/models/user.rb

2
app/jobs/scheme_email_csv_job.rb

@ -9,7 +9,7 @@ class SchemeEmailCsvJob < ApplicationJob
unfiltered_schemes = if organisation.present? && user.support?
Scheme.where(owning_organisation: [organisation] + organisation.parent_organisations)
else
Scheme.where(owning_organisation: [user.organisation] + user.organisation.parent_organisations)
user.schemes
end
filtered_schemes = FilterManager.filter_schemes(unfiltered_schemes, search_term, filters, all_orgs, user)
csv_string = Csv::SchemeCsvService.new(download_type:).prepare_csv(filtered_schemes)

2
app/models/user.rb

@ -113,7 +113,7 @@ class User < ApplicationRecord
if support?
Scheme.all
else
Scheme.filter_by_owning_organisation(organisation.absorbed_organisations + [organisation])
Scheme.filter_by_owning_organisation(organisation.absorbed_organisations + [organisation] + organisation.parent_organisations)
end
end

Loading…
Cancel
Save