diff --git a/CHANGES.rst b/CHANGES.rst index d139578e..f57799e7 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -7,6 +7,8 @@ Changelog - Override BandoView: in io-Comune we add new children on Folder Deepening content and we need to proper handle it [lucabel] +- update serializer for documento ct adding more information about modulo children + [lucabel] 6.2.22 (2024-10-30) ------------------- diff --git a/src/design/plone/contenttypes/restapi/serializers/documento.py b/src/design/plone/contenttypes/restapi/serializers/documento.py index 5a47cca8..9a2a4fd2 100644 --- a/src/design/plone/contenttypes/restapi/serializers/documento.py +++ b/src/design/plone/contenttypes/restapi/serializers/documento.py @@ -52,5 +52,16 @@ def __call__(self, version=None, include_items=True): result = super(DocumentoSerializer, self).__call__( version=version, include_items=include_items ) + # Una via alternativa era l'injection di fullobject nella request ma + # mi pare una cosa cattiva da fare + brain_moduli = [ + x for x in self.context.getFolderContents() if x.portal_type == "Modulo" + ] + result["moduli_del_documento"] = [] + for brain in brain_moduli: + modulo = brain.getObject() + result["moduli_del_documento"].append( + getMultiAdapter((modulo, self.request), ISerializeToJson)() + ) result["servizi_collegati"] = self.get_services() return result