Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add export to education view #28

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

davudevren
Copy link

CSV Export der Ausbildungs-Ansicht

Comment on lines +11 to +34
def event_participations
today = Time.zone.today
entry.event_participations.
select do |p|
p.event.supports_applications? &&
p.event.dates.sort_by(&:start_at).last.start_at >= today
end.
collect do |p|
p.event.name
end.
join(', ')
end

def qualifications
entry.qualifications.
select(&:reactivateable?).
sort_by(&:start_at).
reverse.
uniq(&:qualification_kind).
collect do |q|
"#{q.qualification_kind.label}".strip
end.
join(', ')
end
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not great that this logic is duplicated in large parts from the helper to here.
Maybe you could add the common part of the logic to the Youth::PersonDecorator (e.g. as methods education_event_participations etc.), and then use that here and in the helper.
Either entry.education_event_participations.join(', ') or entry.decorate.education_event_participations.join(', ') should work.

-# or later. See the COPYING file at the top-level directory or at
-# https://github.com/hitobito/hitobito_youth.

= action_button(t('.export_people'), educations_path({format: :csv}.merge(params.to_unsafe_h)), :download)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You added the capability for CSV and XLSX to the controller, but only expose CSV here. Wouldn't XLSX be more valuable? Maybe in the future we might want to color some of the text in the spreadsheet, depending on when some qualifications expire.

The CSV is clearly easier to test though.

@@ -0,0 +1,6 @@
-# Copyright (c) 2023 , Pfadibewegung Schweiz. This file is part of
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
-# Copyright (c) 2023 , Pfadibewegung Schweiz. This file is part of
-# Copyright (c) 2023, Pfadibewegung Schweiz. This file is part of

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants