Skip to content

Commit

Permalink
add has_siblings_in_layer to people full export
Browse files Browse the repository at this point in the history
  • Loading branch information
diegosteiner committed Sep 14, 2023
1 parent 6f26130 commit 510826d
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 6 deletions.
15 changes: 14 additions & 1 deletion app/domain/pbs/export/tabular/people/people_full.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,21 @@ module PeopleFull
end

def person_attributes_with_pbs
person_attributes_without_pbs + [:id, :layer_group_id, :pbs_number]
person_attributes_without_pbs + [:id, :layer_group_id, :pbs_number,
:has_siblings_in_layer]
end

def initialize(list, group)
super(list)
@group = group
end

private

def row_for(entry, format = nil)
row_class.new(entry, format, @group)
end

end
end
end
Expand Down
11 changes: 11 additions & 0 deletions app/domain/pbs/export/tabular/people/person_row.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,13 @@ module People
module PersonRow
extend ActiveSupport::Concern

attr_reader :group

def initialize(entry, format = nil, group = nil)
super(entry, format)
@group = group
end

def salutation
entry.salutation_value
end
Expand All @@ -24,6 +31,10 @@ def layer_group_id
entry.try(:primary_group).try(:layer_group).try(:id)
end

def has_siblings_in_layer
::Person::FamilyMemberFinder.new(entry)
.family_members_in_context(group, kind: :sibling).any?
end
end
end
end
Expand Down
6 changes: 5 additions & 1 deletion app/jobs/pbs/export/people_export_job.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,12 @@ module Pbs::Export::PeopleExportJob
end

def exporter_with_detail
return Pbs::Export::Tabular::People::HouseholdsFull if @options[:household_details]
return Pbs::Export::Tabular::People::HouseholdsFull if @options[:household_details]
exporter_without_detail
end

def data
return super unless exporter == ::Export::Tabular::People::PeopleFull
::Export::Tabular::People::PeopleFull.export(@format, entries, group)
end
end
5 changes: 3 additions & 2 deletions app/serializers/pbs/person_serializer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,9 @@ module Pbs::PersonSerializer
map_properties :pbs_number, :salutation_value, :correspondence_language,
:prefers_digital_correspondence, :grade_of_school, :entry_date, :leaving_date


property :has_siblings_in_layer, item.siblings_in_context(context[:group]).any? if context[:group]
if context[:group].present?
property :has_siblings_in_layer, item.siblings_in_context(context[:group]).any?
end
end

end
Expand Down
3 changes: 1 addition & 2 deletions config/locales/models.pbs.de.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1189,8 +1189,7 @@ de:
leaving_date: Austrittsdatum
j_s_number: J+S Personennummer
correspondence_language: Korrespondenzsprache
brother_and_sisters: Geschwister
relations_to_tails: Geschwister
has_siblings_in_layer: Geschwister in der Ebene
kv: Kantonalverband
prefers_digital_correspondence: Digitale Korrespondenz bevorzugt

Expand Down

0 comments on commit 510826d

Please sign in to comment.