From 1cdf5cb6a1a518e6ccf8b376a34292bfd085cbc9 Mon Sep 17 00:00:00 2001 From: Roman Date: Thu, 2 Nov 2023 09:54:01 +0100 Subject: [PATCH] Squashed commit of the following: commit 22c1e4dc0660e911f446f87e068e6012e2363d18 Author: Roman Date: Thu Nov 2 09:50:11 2023 +0100 Remove cosa_serve field from the Booking Folder commit 354c4cbc2b1dd0c8e35a810cca52aac9a6ce28cf Author: Roman Date: Tue Oct 31 14:46:27 2023 +0100 Fix booking duration type commit 5ffc526b6a58fcacf2b8ee4786b0ba9e86e2d7a9 Merge: d3d4b34 7829bc6 Author: Roman Date: Tue Oct 31 12:07:30 2023 +0100 Merge branch 'develop' into booking_types_ct commit d3d4b34eef8427607557848da6b31b3ca4e3bc8c Author: Roman Date: Tue Oct 31 11:49:43 2023 +0100 Fix booking duration converison commit 8ce51e6e3459eaa2c385f87930c02d27847b556f Author: Roman Date: Tue Oct 31 10:53:12 2023 +0100 Fix booking types duration vocabulary values type commit 34429b6d120378c557216668184232b976927bcd Author: Roman Date: Tue Oct 31 10:39:48 2023 +0100 Fix booking duration handling commit 0af7e6e44aeb037ecb35dc57f5c59d2a868bb382 Author: Roman Date: Tue Oct 31 10:16:20 2023 +0100 Fix BookingType profile commit 142bb8d43d643f007399f51d8906991ceed9f03c Author: Roman Date: Tue Oct 31 10:00:36 2023 +0100 Hide gates commit f748cd7ba6657c63fa106a869cfb2ad370c69d10 Author: Roman Date: Fri Oct 27 17:49:34 2023 +0200 Refactor the @@prenotazioni_context_state.get_booking_type_duration method commit d1209e7ee647f4b90825efa3d6b2e74419cf7545 Author: Roman Date: Thu Oct 26 15:10:41 2023 +0200 Refactor commit 8da8deaffa8d2fbd6ff4d28b6060696ebd600609 Author: Roman Date: Thu Oct 26 15:05:56 2023 +0200 Refactor commit 5aac9ce6cd2f95c57ea4f0e9b44e1ec8c26b6935 Author: Roman Date: Thu Oct 26 14:37:37 2023 +0200 Fix typos commit 190b0ca21d3c4170a312406b5a4c9432e044f7b9 Author: Roman Date: Thu Oct 19 16:54:46 2023 +0200 Initial implementation --- .../browser/templates/prenotazione.pt | 9 ------- .../prenotazioni/content/prenotazione.py | 5 ++++ .../content/prenotazioni_folder.py | 11 -------- .../serializers/adapters/prenotazione.py | 26 +++++++++++-------- .../prenotazioni/tests/test_vacation_api.py | 10 ++++++- src/redturtle/prenotazioni/upgrades.py | 1 + 6 files changed, 30 insertions(+), 32 deletions(-) diff --git a/src/redturtle/prenotazioni/browser/templates/prenotazione.pt b/src/redturtle/prenotazioni/browser/templates/prenotazione.pt index 0377022f..323587ca 100644 --- a/src/redturtle/prenotazioni/browser/templates/prenotazione.pt +++ b/src/redturtle/prenotazioni/browser/templates/prenotazione.pt @@ -123,15 +123,6 @@ Booking code: -
- Cosa serve: - -

 

Generator[BookingType, None, None]: return self.listFolderContents(contentFilter={"portal_type": "BookingType"}) diff --git a/src/redturtle/prenotazioni/restapi/serializers/adapters/prenotazione.py b/src/redturtle/prenotazioni/restapi/serializers/adapters/prenotazione.py index 6b0fd47f..31220679 100644 --- a/src/redturtle/prenotazioni/restapi/serializers/adapters/prenotazione.py +++ b/src/redturtle/prenotazioni/restapi/serializers/adapters/prenotazione.py @@ -5,12 +5,13 @@ from zope.component import adapter, getMultiAdapter from zope.i18n import translate from zope.interface import implementer +from zope.interface.interfaces import ComponentLookupError from zope.publisher.interfaces import IRequest from zope.schema import getFields from redturtle.prenotazioni import logger +from redturtle.prenotazioni.content.booking_type import IBookingType from redturtle.prenotazioni.content.prenotazione import IPrenotazione -from redturtle.prenotazioni.content.prenotazioni_folder import IPrenotazioniFolder from redturtle.prenotazioni.interfaces import ISerializeToPrenotazioneSearchableItem @@ -22,15 +23,18 @@ def __init__(self, prenotazione, request): self.request = request def __call__(self, *args, **kwargs): - booking_folder = self.prenotazione.getPrenotazioniFolder() - useful_docs = getMultiAdapter( - ( - getFields(IPrenotazioniFolder)["cosa_serve"], - booking_folder, - self.request, - ), - IFieldSerializer, - )() + booking_folder = self.prenotazione.getBookingFolder() + try: + requirements = getMultiAdapter( + ( + getFields(IBookingType)["requirements"], + self.prenotazione.get_booking_type(), + self.request, + ), + IFieldSerializer, + )() + except ComponentLookupError: + requirements = "" if self.prenotazione.fiscalcode: fiscalcode = self.prenotazione.fiscalcode.upper() @@ -73,8 +77,8 @@ def __call__(self, *args, **kwargs): "booking_folder_uid": booking_folder.UID(), "vacation": self.prenotazione.isVacation(), "booking_code": self.prenotazione.getBookingCode(), - "cosa_serve": useful_docs, "notify_on_confirm": booking_folder.notify_on_confirm, + "cosa_serve": requirements, } diff --git a/src/redturtle/prenotazioni/tests/test_vacation_api.py b/src/redturtle/prenotazioni/tests/test_vacation_api.py index 1b490d16..256501ec 100644 --- a/src/redturtle/prenotazioni/tests/test_vacation_api.py +++ b/src/redturtle/prenotazioni/tests/test_vacation_api.py @@ -44,7 +44,7 @@ def setUp(self): same_day_booking_disallowed="no", ) - api.content.create( + booking_type_A = api.content.create( type="BookingType", title="Type A", duration=30, @@ -52,6 +52,12 @@ def setUp(self): gates=["all"], ) + api.content.transition( + booking_type_A, + transition="publish", + ) + booking_type_A.reindexObject(idxs=["review_state"]) + week_table = self.folder_prenotazioni.week_table for row in week_table: row["morning_start"] = "0700" @@ -105,6 +111,7 @@ def test_add_vacation(self): ], }, ) + self.assertEqual(res.status_code, 200) # gates[0] is busy because of vacation self.assertEqual(res.json()["gate"], self.folder_prenotazioni.gates[1]) @@ -123,6 +130,7 @@ def test_add_vacation(self): ], }, ) + self.assertEqual(res.status_code, 400) self.assertEqual( res.json()["message"], diff --git a/src/redturtle/prenotazioni/upgrades.py b/src/redturtle/prenotazioni/upgrades.py index 66825a0c..e4e1c72d 100644 --- a/src/redturtle/prenotazioni/upgrades.py +++ b/src/redturtle/prenotazioni/upgrades.py @@ -493,3 +493,4 @@ def to_2000(context): booking_type.reindexObject(idxs=["review_state"]) delattr(obj, "booking_types") + delattr(obj, "cosa_serve")