From 92ac6d5ea3b20b096b02139484c8d7b9ff7735de Mon Sep 17 00:00:00 2001 From: Roman Date: Thu, 12 Oct 2023 09:35:53 +0200 Subject: [PATCH] Refactor the hidden booking types resection techique --- .../restapi/serializers/adapters/prenotazioni_folder.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/redturtle/prenotazioni/restapi/serializers/adapters/prenotazioni_folder.py b/src/redturtle/prenotazioni/restapi/serializers/adapters/prenotazioni_folder.py index ee5a7f5c..c4115917 100644 --- a/src/redturtle/prenotazioni/restapi/serializers/adapters/prenotazioni_folder.py +++ b/src/redturtle/prenotazioni/restapi/serializers/adapters/prenotazioni_folder.py @@ -1,6 +1,4 @@ # -*- coding: utf-8 -*- -from copy import deepcopy - from plone.restapi.interfaces import ISerializeToJson from plone.restapi.serializer.dxcontent import SerializeFolderToJson from zope.component import adapter @@ -16,8 +14,9 @@ class PrenotazioniFolderSerializer(SerializeFolderToJson): def __call__(self, *args, **kwargs): res = super().__call__() - for index, type in enumerate(deepcopy(res.get("booking_types", {}))): - if type.get("hidden"): - del res["booking_types"][index] + if res.get("booking_types"): + res["booking_types"] = [ + t for t in res["booking_types"] if not t.get("hidden") + ] return res