From b1ed59cfd26f308a520771675a13a846e457221e Mon Sep 17 00:00:00 2001 From: Mauro Amico Date: Fri, 20 Sep 2024 15:36:02 +0200 Subject: [PATCH] Workaround for empty contacts UO summaryserializer (#279) Co-authored-by: plone@caligola --- CHANGES.rst | 2 ++ .../restapi/serializers/unita_organizzativa.py | 8 ++++++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/CHANGES.rst b/CHANGES.rst index ff87feb0..6a77658b 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -36,6 +36,8 @@ Changelog 6.2.15 (2024-09-04) ------------------- +- Workaround for empty contacts UO summaryserializer + [mamico] - Add design.plone.contenttypes.behavior.news_base behavior (news metadata, without blocks) [mamico] - Add folder creation (multimedia + allegati) for "ComunicatiStampa" CT (if exists) diff --git a/src/design/plone/contenttypes/restapi/serializers/unita_organizzativa.py b/src/design/plone/contenttypes/restapi/serializers/unita_organizzativa.py index 38a7a022..04b3e5cc 100644 --- a/src/design/plone/contenttypes/restapi/serializers/unita_organizzativa.py +++ b/src/design/plone/contenttypes/restapi/serializers/unita_organizzativa.py @@ -125,10 +125,14 @@ def __call__(self, force_images=True, **kwargs): "contact_info", "sede", ] - for field in fields: if field in ("contact_info", "sede"): - data[field] = json_compatible(getattr(self.context, field, "")) + # XXX: in realta' qui andrebbe usato il serializer specifico per + # i field relationfield, questo perĂ² richiede recuperare il + # il field e il suo serializeadpater, al momento aggiungiamo + # solo un controllo su relazioni non trovate + values = getattr(self.context, field, []) or [] + data[field] = [val for val in json_compatible(values) if val] else: data[field] = getattr(self.context, field, "")