From 796f5519448fc70a68f8e1f0128adeac12af34da Mon Sep 17 00:00:00 2001 From: Roman Kysil Date: Fri, 13 Sep 2024 13:14:43 +0200 Subject: [PATCH] Fix logics --- src/redturtle/prenotazioni/restapi/services/booking/add.py | 5 ++--- .../prenotazioni/restapi/services/booking/update.py | 4 ++-- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/src/redturtle/prenotazioni/restapi/services/booking/add.py b/src/redturtle/prenotazioni/restapi/services/booking/add.py index 50cc5848..d80d0c70 100644 --- a/src/redturtle/prenotazioni/restapi/services/booking/add.py +++ b/src/redturtle/prenotazioni/restapi/services/booking/add.py @@ -164,7 +164,7 @@ def validate(self): raise BadRequest(msg) # booking.additional_fields validation below - additional_fields = data.get("additional_fields") + additional_fields = data.get("additional_fields") or [] # rewrite the fields to prevent not required data additional_fields_data = [] @@ -185,8 +185,7 @@ def validate(self): ) )[0] - for field_schema in booking_type.booking_additional_fields_schema: - + for field_schema in booking_type.booking_additional_fields_schema or []: field = list( filter( lambda i: i.get("name") == field_schema.get("name"), diff --git a/src/redturtle/prenotazioni/restapi/services/booking/update.py b/src/redturtle/prenotazioni/restapi/services/booking/update.py index e93c1647..583877df 100644 --- a/src/redturtle/prenotazioni/restapi/services/booking/update.py +++ b/src/redturtle/prenotazioni/restapi/services/booking/update.py @@ -25,7 +25,7 @@ def handle_additional_fields(self): if data: # booking.additional_fields validation below - additional_fields = data.get("additional_fields") + additional_fields = data.get("additional_fields") or [] # rewrite the fields to prevent not required data additional_fields_data = [] @@ -41,7 +41,7 @@ def handle_additional_fields(self): booking_type = self.context.get_booking_type() - for field_schema in booking_type.booking_additional_fields_schema: + for field_schema in booking_type.booking_additional_fields_schema or []: field = list( filter( lambda i: i.get("name") == field_schema.get("name"),