diff --git a/src/redturtle/prenotazioni/browser/prenotazioni_context_state.py b/src/redturtle/prenotazioni/browser/prenotazioni_context_state.py index 5e815f2e..55b0a63d 100644 --- a/src/redturtle/prenotazioni/browser/prenotazioni_context_state.py +++ b/src/redturtle/prenotazioni/browser/prenotazioni_context_state.py @@ -853,12 +853,11 @@ def booking_type_durations(self): def get_booking_type_duration(self, booking_type): """Return the seconds for this booking_type""" - if type(booking_type) is BookingType: return int(booking_type.duration) * 60 if type(booking_type) is str: - return int(self.booking_type_durations.get(booking_type, 1)) + return self.booking_type_durations.get(booking_type, 1) # XXX: se il booking_type non esiste, ritorna 1 minuto, รจ corretto ???? return 1 diff --git a/src/redturtle/prenotazioni/restapi/serializers/adapters/configure.zcml b/src/redturtle/prenotazioni/restapi/serializers/adapters/configure.zcml index 1e182b7e..44861e6e 100644 --- a/src/redturtle/prenotazioni/restapi/serializers/adapters/configure.zcml +++ b/src/redturtle/prenotazioni/restapi/serializers/adapters/configure.zcml @@ -7,5 +7,6 @@ + diff --git a/src/redturtle/prenotazioni/restapi/serializers/adapters/prenotazioni_folder.py b/src/redturtle/prenotazioni/restapi/serializers/adapters/prenotazioni_folder.py new file mode 100644 index 00000000..acaf9834 --- /dev/null +++ b/src/redturtle/prenotazioni/restapi/serializers/adapters/prenotazioni_folder.py @@ -0,0 +1,25 @@ +# -*- coding: utf-8 -*- +from plone.restapi.interfaces import ISerializeToJson +from plone.restapi.serializer.dxcontent import SerializeFolderToJson +from zope.component import adapter, getMultiAdapter +from zope.interface import implementer + +from redturtle.prenotazioni.content.prenotazioni_folder import IPrenotazioniFolder +from redturtle.prenotazioni.interfaces import ( + IRedturtlePrenotazioniLayer, + ISerializeToRetroCompatibleJson, +) + + +@implementer(ISerializeToJson) +@adapter(IPrenotazioniFolder, IRedturtlePrenotazioniLayer) +class PrenotazioniFolderSerializer(SerializeFolderToJson): + def __call__(self, *args, **kwargs): + res = super().__call__() + + res["booking_types"] = [ + getMultiAdapter((i, self.request), ISerializeToRetroCompatibleJson)() + for i in self.context.get_booking_types() + ] + + return res diff --git a/src/redturtle/prenotazioni/vocabularies/voc_durata_incontro.py b/src/redturtle/prenotazioni/vocabularies/voc_durata_incontro.py index 9d4495b4..1dbe6259 100644 --- a/src/redturtle/prenotazioni/vocabularies/voc_durata_incontro.py +++ b/src/redturtle/prenotazioni/vocabularies/voc_durata_incontro.py @@ -20,7 +20,7 @@ class VocDurataIncontro(object): """ """ def __call__(self, context): - items = [VocabItem(str(x), str(x)) for x in range(10, 95, 5)] + items = [VocabItem(x, x) for x in range(10, 95, 5)] if not IDexterityContent.providedBy(context): req = getRequest()