Skip to content

Commit

Permalink
Refactor the hidden booking types resection techique
Browse files Browse the repository at this point in the history
  • Loading branch information
folix-01 committed Oct 12, 2023
1 parent b24d268 commit 92ac6d5
Showing 1 changed file with 4 additions and 5 deletions.
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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

0 comments on commit 92ac6d5

Please sign in to comment.