From 4cf8c87e74b378fa30835d3532996fd8c53f25a2 Mon Sep 17 00:00:00 2001 From: Carlo Beltrame Date: Mon, 23 Aug 2021 19:51:11 +0200 Subject: [PATCH] Add additional fields for group health to API --- app/models/pbs/person.rb | 3 ++- app/serializers/pbs/people_serializer.rb | 21 +++++++++++++++++++++ lib/hitobito_pbs/wagon.rb | 1 + 3 files changed, 24 insertions(+), 1 deletion(-) create mode 100644 app/serializers/pbs/people_serializer.rb diff --git a/app/models/pbs/person.rb b/app/models/pbs/person.rb index 9db94b831..d3b826bc7 100644 --- a/app/models/pbs/person.rb +++ b/app/models/pbs/person.rb @@ -57,7 +57,8 @@ module Pbs::Person included do Person::PUBLIC_ATTRS << :title << :salutation << :correspondence_language << - :prefers_digital_correspondence << :kantonalverband_id + :prefers_digital_correspondence << :kantonalverband_id << + :pbs_number << :entry_date << :leaving_date alias_method_chain :full_name, :title diff --git a/app/serializers/pbs/people_serializer.rb b/app/serializers/pbs/people_serializer.rb new file mode 100644 index 000000000..edb3c173a --- /dev/null +++ b/app/serializers/pbs/people_serializer.rb @@ -0,0 +1,21 @@ +# encoding: utf-8 + +# Copyright (c) 2021, Pfadibewegung 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. + +module Pbs::PeopleSerializer + extend ActiveSupport::Concern + + included do + extension(:public) do |_| + details = h.can?(:show_details, item) + if details + map_properties :gender, :birthday, :pbs_number, :entry_date, :leaving_date, + :primary_group_id + end + end + end + +end diff --git a/lib/hitobito_pbs/wagon.rb b/lib/hitobito_pbs/wagon.rb index fba46fe8d..3193525cd 100644 --- a/lib/hitobito_pbs/wagon.rb +++ b/lib/hitobito_pbs/wagon.rb @@ -95,6 +95,7 @@ class Wagon < Rails::Engine ### serializers PersonSerializer.include Pbs::PersonSerializer + PeopleSerializer.include Pbs::PeopleSerializer GroupSerializer.include Pbs::GroupSerializer EventSerializer.include Pbs::EventSerializer EventParticipationSerializer.include Pbs::EventParticipationSerializer