Skip to content

Commit

Permalink
hitobito_jubla#78: Verwalter*innen bei Anmeldung anzeigen (#133)
Browse files Browse the repository at this point in the history
* feat: add manager to participation pdf (hitobito_jubla#78)

* fix: linting (hitobito_jubla#78)
  • Loading branch information
diegosteiner authored Dec 5, 2024
1 parent 49f5a9a commit c7a0fe1
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 0 deletions.
13 changes: 13 additions & 0 deletions app/domain/jubla/export/pdf/participation.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ def render
super
labeled_attr(person, :originating_flock)
labeled_attr(person, :originating_state)
render_people_managers
end

def person_attributes
Expand All @@ -33,6 +34,18 @@ def address_details
zip_code, town = super
[zip_code, [town, person.canton].compact_blank.join(", ")]
end

def render_people_managers
return unless person.people_managers.any?

with_settings(font_size: 7) do
move_down_line
text PeopleManager.model_name.human(count: person.people_managers.count), style: :bold
person.people_managers&.each do |manager|
text "#{manager.manager}: #{[manager.email, manager.phone_number&.number].compact_blank.join(", ")}"
end
end
end
end

self.person_section = Person
Expand Down
30 changes: 30 additions & 0 deletions spec/domain/export/pdf/participation_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# Copyright (c) 2012-2023, Jungwacht Blauring Schweiz. This file is part of
# hitobito 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.

require "spec_helper"

describe Export::Pdf::Participation do
include PdfHelpers

let(:participation) { event_participations(:top_participant) }
let!(:managers) do
2.times.map do
Fabricate(:person).tap do |manager|
manager.phone_numbers.create(number: "+41 44 123 45 57", label: "Privat")
participation.person.managers << manager
end
end
end
subject(:pdf) { described_class.render(participation) }

it "renders with all managers" do
expect(participation.person.managers).to contain_exactly(*managers)
text = PDF::Inspector::Text.analyze(pdf).show_text.join(' ')
expect(text).to include(PeopleManager.model_name.human(count: 1))
managers.each do |manager|
expect(text).to include("#{manager}: #{manager.email}, #{manager.phone_numbers.first.number}")
end
end
end

0 comments on commit c7a0fe1

Please sign in to comment.