Skip to content

Commit

Permalink
Merge branch 'develop' into booking_types_ct
Browse files Browse the repository at this point in the history
  • Loading branch information
folix-01 committed Oct 31, 2023
2 parents d3d4b34 + 7829bc6 commit 5ffc526
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,6 @@
<adapter factory=".prenotazione.PrenotazioneSerializer" />
<adapter factory=".prenotazione.PrenotazioneSearchableItemSerializer" />
<adapter factory=".booking_type.BookingTypeRetroCompatibleSerializer" />
<adapter factory=".prenotazioni_folder.PrenotazioniFolderSerializer" />

</configure>
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down

0 comments on commit 5ffc526

Please sign in to comment.