diff --git a/src/iosanita/contenttypes/interfaces/cartella_modulistica.py b/src/iosanita/contenttypes/interfaces/cartella_modulistica.py index 04638bb..3bafe2b 100644 --- a/src/iosanita/contenttypes/interfaces/cartella_modulistica.py +++ b/src/iosanita/contenttypes/interfaces/cartella_modulistica.py @@ -18,3 +18,13 @@ class ICartellaModulistica(model.Schema, IIosanitaContenttypes): required=False, default=False, ) + + ricerca_in_testata = schema.Bool( + title=_("ricerca_in_testata_label", default="Ricerca in testata"), + default=False, + required=False, + description=_( + "ricerca_in_testata_help", + default="Seleziona se mostrare o meno il campo di ricerca in testata.", + ), + ) diff --git a/src/iosanita/contenttypes/restapi/serializers/configure.zcml b/src/iosanita/contenttypes/restapi/serializers/configure.zcml index 30e3e83..00c1358 100644 --- a/src/iosanita/contenttypes/restapi/serializers/configure.zcml +++ b/src/iosanita/contenttypes/restapi/serializers/configure.zcml @@ -6,6 +6,7 @@ + diff --git a/src/iosanita/contenttypes/restapi/serializers/modulo.py b/src/iosanita/contenttypes/restapi/serializers/modulo.py new file mode 100644 index 0000000..bcb5aee --- /dev/null +++ b/src/iosanita/contenttypes/restapi/serializers/modulo.py @@ -0,0 +1,37 @@ +# -*- coding: utf-8 -*- +from iosanita.contenttypes.interfaces import IIosanitaContenttypesLayer +from iosanita.contenttypes.interfaces.modulo import IModulo +from iosanita.contenttypes.restapi.serializers.summary import ( + DefaultJSONSummarySerializer, +) +from plone.dexterity.utils import iterSchemata +from plone.restapi.interfaces import IFieldSerializer +from plone.restapi.interfaces import ISerializeToJsonSummary +from zope.component import adapter +from zope.component import queryMultiAdapter +from zope.interface import implementer +from zope.schema import getFields + + +@implementer(ISerializeToJsonSummary) +@adapter(IModulo, IIosanitaContenttypesLayer) +class SerializeModuloToJsonSummary(DefaultJSONSummarySerializer): + def __call__(self, **kwargs): + summary = super().__call__(**kwargs) + fields = [ + "file", + "formato_alternativo_1", + "formato_alternativo_2", + ] + for schema in iterSchemata(self.context): + for name, field in getFields(schema).items(): + if name not in fields: + continue + + # serialize the field + serializer = queryMultiAdapter( + (field, self.context, self.request), IFieldSerializer + ) + value = serializer() + summary[name] = value + return summary \ No newline at end of file