From 83846577aef3b2b983f3b95f3cefdfa3063c8b4d Mon Sep 17 00:00:00 2001 From: Joaquim Nallar Date: Wed, 13 Sep 2023 09:07:36 +0200 Subject: [PATCH] feat: add organizer_id on TouristicEvent endpoint (refs #3587) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Avant: Il manquait l'id de l'organisateur d'un événement. Maintenant: L'id est rajouté sur l'événement. --- docs/changelog.rst | 1 + geotrek/api/tests/test_v2.py | 2 +- geotrek/api/v2/serializers.py | 5 ++++- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/docs/changelog.rst b/docs/changelog.rst index 586bc07f67..767d402383 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -8,6 +8,7 @@ CHANGELOG **Improvements** - Remove 'review' field on ServiceType (#1669) +- Add organizer_id on TouristicEvent endpoint ( #3587) **Documentation** diff --git a/geotrek/api/tests/test_v2.py b/geotrek/api/tests/test_v2.py index 13deb43f6a..e00fa35544 100644 --- a/geotrek/api/tests/test_v2.py +++ b/geotrek/api/tests/test_v2.py @@ -222,7 +222,7 @@ TOURISTIC_EVENT_DETAIL_JSON_STRUCTURE = sorted([ 'id', 'accessibility', 'approved', 'attachments', 'begin_date', 'bookable', 'booking', 'cities', 'contact', 'create_datetime', 'description', 'description_teaser', 'districts', 'duration', 'email', 'end_date', 'external_id', 'geometry', - 'meeting_point', 'start_time', 'meeting_time', 'end_time', 'name', 'organizer', 'capacity', 'pdf', 'place', 'portal', + 'meeting_point', 'start_time', 'meeting_time', 'end_time', 'name', 'organizer', 'organizer_id', 'capacity', 'pdf', 'place', 'portal', 'practical_info', 'provider', 'published', 'source', 'speaker', 'structure', 'target_audience', 'themes', 'type', 'update_datetime', 'url', 'uuid', 'website', 'cancelled', 'cancellation_reason', 'participant_number' ]) diff --git a/geotrek/api/v2/serializers.py b/geotrek/api/v2/serializers.py index 26306e37b9..438cda4351 100644 --- a/geotrek/api/v2/serializers.py +++ b/geotrek/api/v2/serializers.py @@ -505,6 +505,9 @@ class TouristicEventSerializer(TouristicModelSerializer): read_only=True, slug_field='label' ) + organizer_id = serializers.PrimaryKeyRelatedField( + read_only=True + ) attachments = AttachmentSerializer(many=True, source='sorted_attachments') url = HyperlinkedIdentityField(view_name='apiv2:touristicevent-detail') begin_date = serializers.DateField() @@ -547,7 +550,7 @@ class Meta(TimeStampedSerializer.Meta): 'booking', 'cancellation_reason', 'cancelled', 'capacity', 'cities', 'contact', 'description', 'description_teaser', 'districts', 'duration', 'email', 'end_date', 'end_time', 'external_id', 'geometry', 'meeting_point', - 'meeting_time', 'name', 'organizer', 'participant_number', 'pdf', 'place', + 'meeting_time', 'name', 'organizer', 'organizer_id', 'participant_number', 'pdf', 'place', 'portal', 'practical_info', 'provider', 'published', 'source', 'speaker', 'start_time', 'structure', 'target_audience', 'themes', 'type', 'url', 'uuid', 'website'