From 70d0cc67bc986eb1d5f1636bc12da5289b2c8ecf Mon Sep 17 00:00:00 2001 From: Carlo Beltrame Date: Sun, 26 Mar 2023 03:39:44 +0200 Subject: [PATCH 1/2] Only show NDS course and camp export when appropriate --- app/helpers/pbs/dropdown/people_export.rb | 23 +++++++++++++++++++++++ lib/hitobito_pbs/wagon.rb | 1 + 2 files changed, 24 insertions(+) create mode 100644 app/helpers/pbs/dropdown/people_export.rb diff --git a/app/helpers/pbs/dropdown/people_export.rb b/app/helpers/pbs/dropdown/people_export.rb new file mode 100644 index 000000000..1a4f91e24 --- /dev/null +++ b/app/helpers/pbs/dropdown/people_export.rb @@ -0,0 +1,23 @@ +# frozen_string_literal: true + +# Copyright (c) 2023, Pfadibewegung Schweiz. This file is part of +# hitobito_pbs and licensed under the Affero General Public License version 3 +# or later. See the COPYING file at the top-level directory or at +# https://github.com/hitobito/hitobito_pbs. + +module Pbs + module Dropdown + module PeopleExport + extend ActiveSupport::Concern + + def is_course?(event) + event.is_a?(::Event::Course) + end + + def is_camp?(event) + event.is_a?(::Event::Camp) + end + + end + end +end diff --git a/lib/hitobito_pbs/wagon.rb b/lib/hitobito_pbs/wagon.rb index 01903a5b6..1c5ec10ef 100644 --- a/lib/hitobito_pbs/wagon.rb +++ b/lib/hitobito_pbs/wagon.rb @@ -142,6 +142,7 @@ class Wagon < Rails::Engine admin = NavigationHelper::MAIN.find { |opts| opts[:label] == :admin } admin[:active_for] << 'black_lists' ContactAttrs::ControlBuilder.include Pbs::ContactAttrs::ControlBuilder + Dropdown::PeopleExport.include Pbs::Dropdown::PeopleExport ### jobs Event::ParticipationConfirmationJob.include Pbs::Event::ParticipationConfirmationJob From 6ae6fae9ce6beca444d64154dc921390e73bafbd Mon Sep 17 00:00:00 2001 From: Carlo Beltrame Date: Sun, 26 Mar 2023 04:21:10 +0200 Subject: [PATCH 2/2] Always export only participants, regardless of filters Fixes hitobito/hitobito#1733 --- .../export/event_participations_export_job.rb | 29 ++++++++++++++----- config/locales/views.pbs.de.yml | 5 ++++ lib/hitobito_pbs/wagon.rb | 2 +- 3 files changed, 28 insertions(+), 8 deletions(-) diff --git a/app/jobs/pbs/export/event_participations_export_job.rb b/app/jobs/pbs/export/event_participations_export_job.rb index 31e505db6..3ff4f3a28 100644 --- a/app/jobs/pbs/export/event_participations_export_job.rb +++ b/app/jobs/pbs/export/event_participations_export_job.rb @@ -6,17 +6,32 @@ # https://github.com/hitobito/hitobito. module Pbs::Export::EventParticipationsExportJob - extend ActiveSupport::Concern - included do - alias_method_chain :exporter, :detail - end - - def exporter_with_detail + def exporter if @options[:household_details] return Pbs::Export::Tabular::People::ParticipationsHouseholdsFull end - exporter_without_detail + super + end + + def entries + filtered = super + if @options[:nds_course] && ability.can?(:show_details, filtered.first) + unfiltered_participants + elsif @options[:nds_camp] && ability.can?(:show_details, filtered.first) + unfiltered_participants + elsif @options[:slrg] && ability.can?(:show_details, filtered.first) + unfiltered_participants + else + super + end + end + + def unfiltered_participants + @filter.event.participants_scope. + includes(::Event::ParticipationFilter.load_entries_includes). + references(:people). + distinct end end diff --git a/config/locales/views.pbs.de.yml b/config/locales/views.pbs.de.yml index 2a39cfa1f..287c5b9d5 100644 --- a/config/locales/views.pbs.de.yml +++ b/config/locales/views.pbs.de.yml @@ -408,3 +408,8 @@ de: global: title_event/camp: Lager + + dropdown/people_export: + nds_course: NDS-Kurs (nur TN) + nds_camp: NDS-Lager (nur TN) + slrg: SLRG-Kurs (nur TN) diff --git a/lib/hitobito_pbs/wagon.rb b/lib/hitobito_pbs/wagon.rb index 1c5ec10ef..c98bce622 100644 --- a/lib/hitobito_pbs/wagon.rb +++ b/lib/hitobito_pbs/wagon.rb @@ -65,7 +65,7 @@ class Wagon < Rails::Engine Export::Tabular::People::PeopleFull.include Pbs::Export::Tabular::People::PeopleFull Export::Tabular::Events::BsvRow.include Pbs::Export::Tabular::Events::BsvRow Export::PeopleExportJob.include Pbs::Export::PeopleExportJob - Export::EventParticipationsExportJob.include Pbs::Export::EventParticipationsExportJob + Export::EventParticipationsExportJob.prepend Pbs::Export::EventParticipationsExportJob Export::SubscriptionsJob.include Pbs::Export::SubscriptionsJob Person::AddRequest::Approver::Event.prepend(