Skip to content

Commit

Permalink
Add bookign_types to PrenotazioniFolder serialized to JSON
Browse files Browse the repository at this point in the history
  • Loading branch information
folix-01 committed Oct 30, 2023
1 parent b5c52aa commit 7cfee69
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
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

0 comments on commit 7cfee69

Please sign in to comment.