Skip to content

Commit

Permalink
Merge pull request #263 from hitobito/slrg-participant-export
Browse files Browse the repository at this point in the history
Improve camp and course participant exports
  • Loading branch information
carlobeltrame authored Mar 29, 2023
2 parents ad8bd36 + 6ae6fae commit 12fc113
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 8 deletions.
23 changes: 23 additions & 0 deletions app/helpers/pbs/dropdown/people_export.rb
Original file line number Diff line number Diff line change
@@ -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
29 changes: 22 additions & 7 deletions app/jobs/pbs/export/event_participations_export_job.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
5 changes: 5 additions & 0 deletions config/locales/views.pbs.de.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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)
3 changes: 2 additions & 1 deletion lib/hitobito_pbs/wagon.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 12fc113

Please sign in to comment.