diff --git a/CHANGES.rst b/CHANGES.rst index 85e55f6..328bb19 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -4,7 +4,8 @@ Changelog 1.1.11 (unreleased) ------------------- -- Nothing changed yet. +- Handle missing infos in prenotazioniFolder serializer. + [cekk] 1.1.10 (2023-10-16) diff --git a/src/design/plone/ioprenoto/restapi/serializers/ovverrides/prenotazioniFolder.py b/src/design/plone/ioprenoto/restapi/serializers/ovverrides/prenotazioniFolder.py index cefd3e6..76a2243 100644 --- a/src/design/plone/ioprenoto/restapi/serializers/ovverrides/prenotazioniFolder.py +++ b/src/design/plone/ioprenoto/restapi/serializers/ovverrides/prenotazioniFolder.py @@ -26,11 +26,11 @@ def __call__(self, *args, **kwargs): ): # XXX: this is a workaround to avoid the Unauthorized exception return { - "@components": resp["@components"], - "@id": resp["@id"], - "@type": resp["@type"], - "layout": resp["layout"], - "title": resp["title"], + "@components": resp.get("@components", {}), + "@id": resp.get("@id", ""), + "@type": resp.get("@type", ""), + "layout": resp.get("@layout", ""), + "title": resp.get("@title", ""), "error": "Unauthorized", "anonymous": api.user.is_anonymous(), } diff --git a/src/design/plone/ioprenoto/tests/test_prenotazione_add.py b/src/design/plone/ioprenoto/tests/test_prenotazione_add.py index d239c74..c51d5e8 100644 --- a/src/design/plone/ioprenoto/tests/test_prenotazione_add.py +++ b/src/design/plone/ioprenoto/tests/test_prenotazione_add.py @@ -23,9 +23,6 @@ def setUp(self): title="Prenota foo", description="", daData=date.today(), - booking_types=[ - {"name": "Type A", "duration": "30"}, - ], gates=["Gate A"], ) week_table = self.folder_prenotazioni.week_table @@ -33,7 +30,17 @@ def setUp(self): row["morning_start"] = "0700" row["morning_end"] = "1000" self.folder_prenotazioni.week_table = week_table + + booking_type_a = api.content.create( + type="PrenotazioneType", + title="Type A", + duration=30, + container=self.folder_prenotazioni, + gates=["all"], + ) + api.content.transition(obj=self.folder_prenotazioni, transition="publish") + api.content.transition(obj=booking_type_a, transition="publish") transaction.commit() self.api_session = RelativeSession(self.portal_url)