diff --git a/src/iosanita/contenttypes/adapters/schema_tweaks.py b/src/iosanita/contenttypes/adapters/schema_tweaks.py index 39f223d..2821b03 100644 --- a/src/iosanita/contenttypes/adapters/schema_tweaks.py +++ b/src/iosanita/contenttypes/adapters/schema_tweaks.py @@ -20,7 +20,7 @@ def __init__(self, schema): self.schema = schema def __call__(self): - self.set_description_required() + # self.set_description_required() self.fix_bando() def set_description_required(self): diff --git a/src/iosanita/contenttypes/restapi/services/types/get.py b/src/iosanita/contenttypes/restapi/services/types/get.py index 8f78691..2dbc6f5 100644 --- a/src/iosanita/contenttypes/restapi/services/types/get.py +++ b/src/iosanita/contenttypes/restapi/services/types/get.py @@ -2,6 +2,7 @@ from plone.restapi.services.types.get import TypesGet as BaseGet from zope.interface import implementer from zope.publisher.interfaces import IPublishTraverse +from iosanita.contenttypes.interfaces import IoSanitaMigrationMarker class FieldsetsMismatchError(Exception): @@ -139,7 +140,28 @@ def customize_versioning_fields_fieldset(self, result): if fieldset.get("id") == "settings" and found: fieldset["fields"].append(field) - return result + # return result + + def set_description_required(self, result): + if IoSanitaMigrationMarker.providedBy(self.request): + return + portal_types = [ + "Servizio", + "ComeFarePer", + "Struttura", + "News Item", + "Event", + "UnitaOrganizzativa", + "Documento", + "Bando", + ] + + if ( + self.request.steps[-1] in portal_types + and "description" in result["properties"] # noqa + and "description" not in result["required"] # noqa + ): + result["required"].append("description") def reply(self): result = super(TypesGet, self).reply() @@ -147,7 +169,8 @@ def reply(self): result["fieldsets"] = self.reorder_fieldsets(schema=result) if "title" in result: - result = self.customize_versioning_fields_fieldset(result) + self.customize_versioning_fields_fieldset(result) + self.set_description_required(result) return result def get_order_by_type(self, portal_type): diff --git a/src/iosanita/contenttypes/tests/test_ct_bando.py b/src/iosanita/contenttypes/tests/test_ct_bando.py index 4621cd0..21b458f 100644 --- a/src/iosanita/contenttypes/tests/test_ct_bando.py +++ b/src/iosanita/contenttypes/tests/test_ct_bando.py @@ -90,7 +90,7 @@ def test_bando_required_fields(self): "descrizione_estesa", "come_partecipare", "modalita_selezione", - # "description", is required from schema_tweaks.py but it doesn't apply in test + "description", ] ), ) diff --git a/src/iosanita/contenttypes/tests/test_ct_come_fare_per.py b/src/iosanita/contenttypes/tests/test_ct_come_fare_per.py index a27902e..f17e187 100644 --- a/src/iosanita/contenttypes/tests/test_ct_come_fare_per.py +++ b/src/iosanita/contenttypes/tests/test_ct_come_fare_per.py @@ -86,7 +86,7 @@ def test_come_fare_per_required_fields(self): [ "panoramica", "title", - # "description", is required from schema_tweaks.py but it doesn't apply in test + "description", ] ), ) diff --git a/src/iosanita/contenttypes/tests/test_ct_documento.py b/src/iosanita/contenttypes/tests/test_ct_documento.py index d52a74a..29a78a3 100644 --- a/src/iosanita/contenttypes/tests/test_ct_documento.py +++ b/src/iosanita/contenttypes/tests/test_ct_documento.py @@ -91,7 +91,7 @@ def test_documento_required_fields(self): "descrizione_estesa", "uo_correlata", "file", - # "description", is required from schema_tweaks.py but it doesn't apply in test + "description", ] ), ) diff --git a/src/iosanita/contenttypes/tests/test_ct_event.py b/src/iosanita/contenttypes/tests/test_ct_event.py index d88bcfa..16cf767 100644 --- a/src/iosanita/contenttypes/tests/test_ct_event.py +++ b/src/iosanita/contenttypes/tests/test_ct_event.py @@ -102,7 +102,7 @@ def test_event_required_fields(self): "start", "tipologia_evento", "title", - # "description", is required from schema_tweaks.py but it doesn't apply in test + "description", ] ), ) diff --git a/src/iosanita/contenttypes/tests/test_ct_modulo.py b/src/iosanita/contenttypes/tests/test_ct_modulo.py index 218227f..f2f557e 100644 --- a/src/iosanita/contenttypes/tests/test_ct_modulo.py +++ b/src/iosanita/contenttypes/tests/test_ct_modulo.py @@ -72,7 +72,6 @@ def test_modulo_required_fields(self): [ "title", "file", - # "description", is required from schema_tweaks.py but it doesn't apply in test ] ), ) diff --git a/src/iosanita/contenttypes/tests/test_ct_news.py b/src/iosanita/contenttypes/tests/test_ct_news.py index ca2ec26..a0c396f 100644 --- a/src/iosanita/contenttypes/tests/test_ct_news.py +++ b/src/iosanita/contenttypes/tests/test_ct_news.py @@ -86,7 +86,7 @@ def test_bando_required_fields(self): "descrizione_estesa", "title", "uo_correlata", - # "description", is required from schema_tweaks.py but it doesn't apply in test + "description", ] ), ) diff --git a/src/iosanita/contenttypes/tests/test_ct_servizio.py b/src/iosanita/contenttypes/tests/test_ct_servizio.py index a80d4f2..a53425d 100644 --- a/src/iosanita/contenttypes/tests/test_ct_servizio.py +++ b/src/iosanita/contenttypes/tests/test_ct_servizio.py @@ -103,7 +103,7 @@ def test_servizio_required_fields(self): "come_accedere", "tempi_attesa", "costi", - # "description", is required from schema_tweaks.py but it doesn't apply in test + "description", "orari", "uo_correlata", "responsabile_correlato", @@ -260,7 +260,7 @@ def test_servizio_default_children(self): container=self.portal, type="Servizio", title="xxx" ) - self.assertEqual(servizio.keys(), ["allegati"]) + self.assertEqual(servizio.keys(), ["modulistica", "allegati"]) def test_servizio_allegati_has_filtered_addable_types(self): servizio = api.content.create( diff --git a/src/iosanita/contenttypes/tests/test_ct_struttura.py b/src/iosanita/contenttypes/tests/test_ct_struttura.py index 4c32a12..97e4c1f 100644 --- a/src/iosanita/contenttypes/tests/test_ct_struttura.py +++ b/src/iosanita/contenttypes/tests/test_ct_struttura.py @@ -97,7 +97,7 @@ def test_struttura_required_fields(self): sorted( [ "come_accedere", - # "description", is required from schema_tweaks.py but it doesn't apply in test + "description", "orari", "pdc_correlato", "responsabile_correlato", diff --git a/src/iosanita/contenttypes/tests/test_ct_uo.py b/src/iosanita/contenttypes/tests/test_ct_uo.py index c0966dd..65d6f83 100644 --- a/src/iosanita/contenttypes/tests/test_ct_uo.py +++ b/src/iosanita/contenttypes/tests/test_ct_uo.py @@ -90,7 +90,7 @@ def test_uo_required_fields(self): sorted( [ "competenze", - # "description", is required from schema_tweaks.py but it doesn't apply in test + "description", "orari", "pdc_correlato", "responsabile_correlato",