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"),