diff --git a/src/iosanita/contenttypes/content/documento.py b/src/iosanita/contenttypes/content/documento.py
new file mode 100644
index 0000000..b11f577
--- /dev/null
+++ b/src/iosanita/contenttypes/content/documento.py
@@ -0,0 +1,9 @@
+# -*- coding: utf-8 -*-
+from iosanita.contenttypes.interfaces.documento import IDocumento
+from plone.dexterity.content import Container
+from zope.interface import implementer
+
+
+@implementer(IDocumento)
+class Documento(Container):
+ """ """
diff --git a/src/iosanita/contenttypes/interfaces/documento.py b/src/iosanita/contenttypes/interfaces/documento.py
new file mode 100644
index 0000000..fc75f5c
--- /dev/null
+++ b/src/iosanita/contenttypes/interfaces/documento.py
@@ -0,0 +1,122 @@
+# -*- coding: utf-8 -*-
+
+from collective.volto.blocksfield.field import BlocksField
+from iosanita.contenttypes import _
+from iosanita.contenttypes.interfaces import IIosanitaContenttypes
+from plone.app.z3cform.widget import RelatedItemsFieldWidget
+from plone.autoform import directives as form
+from plone.supermodel import model
+from z3c.relationfield.schema import RelationChoice
+from z3c.relationfield.schema import RelationList
+from zope import schema
+
+
+class IDocumento(model.Schema, IIosanitaContenttypes):
+ """Marker interface for content type"""
+
+ protocollo = schema.TextLine(
+ title=_(
+ "protocollo_documento_label",
+ default="Numero di protocollo",
+ ),
+ description=_(
+ "protocollo_documento_help",
+ default="Il numero di protocollo del documento.",
+ ),
+ max_length=255,
+ required=False,
+ )
+
+ data_protocollo = schema.Date(
+ title=_("data_protocollo", default="Data del protocollo"),
+ required=False,
+ )
+
+ descrizione_estesa = BlocksField(
+ title=_("descrizione_estesa_label", default="Cos'è"),
+ required=True,
+ description=_(
+ "descrizione_estesa_documento_help",
+ default="Descrizione estesa e completa del Documento.",
+ ),
+ )
+
+ # formati_alternativi = BlocksField(
+ # title=_("formati_alternativi_label", default="Formati disponibili"),
+ # description=_(
+ # "formati_alternativi_help",
+ # default="Lista dei formati in cui è disponibile il documento",
+ # ),
+ # required=True,
+ # )
+
+ servizio_procedura_riferimento = RelationList(
+ title=_(
+ "servizio_procedura_riferimento_label",
+ default="Servizio di riferimento / Procedura di riferimento",
+ ),
+ description=_(
+ "servizio_procedura_riferimento_help",
+ default="Indicazione del servizio, la prestazione o la procedura (Come fare per) a cui fa riferimento il documento.",
+ ),
+ default=[],
+ value_type=RelationChoice(vocabulary="plone.app.vocabularies.Catalog"),
+ required=False,
+ missing_value=(),
+ )
+
+ uo_correlata = RelationList(
+ title=_("uo_correlata_documento_label", default="Responsabile del documento"),
+ default=[],
+ value_type=RelationChoice(vocabulary="plone.app.vocabularies.Catalog"),
+ required=True,
+ missing_value=(),
+ )
+
+ autori = RelationList(
+ title=_(
+ "autori_label",
+ default="Autore/i",
+ ),
+ description=_(
+ "autori_help",
+ default="Seleziona una lista di autori che hanno pubblicato "
+ "il documento.",
+ ),
+ value_type=RelationChoice(vocabulary="plone.app.vocabularies.Catalog"),
+ required=False,
+ default=[],
+ )
+
+ # widgets
+ form.widget(
+ "uo_correlata",
+ RelatedItemsFieldWidget,
+ vocabulary="plone.app.vocabularies.Catalog",
+ pattern_options={
+ "maximumSelectionSize": 1,
+ "selectableTypes": ["UnitaOrganizzativa"],
+ },
+ )
+ form.widget(
+ "autori",
+ RelatedItemsFieldWidget,
+ vocabulary="plone.app.vocabularies.Catalog",
+ pattern_options={
+ "selectableTypes": ["Persona"],
+ },
+ )
+ form.widget(
+ "servizio_procedura_riferimento",
+ RelatedItemsFieldWidget,
+ vocabulary="plone.app.vocabularies.Catalog",
+ pattern_options={
+ "selectableTypes": ["ComeFarePer", "Servizio"],
+ },
+ )
+
+ model.fieldset(
+ "cosa_e",
+ label=_("cosa_e_fieldset", default="Cos'è"),
+ fields=["descrizione_estesa"],
+ )
diff --git a/src/iosanita/contenttypes/permissions.zcml b/src/iosanita/contenttypes/permissions.zcml
index b4108b6..5fc811a 100644
--- a/src/iosanita/contenttypes/permissions.zcml
+++ b/src/iosanita/contenttypes/permissions.zcml
@@ -39,6 +39,10 @@
id="iosanita.contenttypes.AddServizio"
title="iosanita.contenttypes: Add Servizio"
/>
+
diff --git a/src/iosanita/contenttypes/profiles/default/rolemap.xml b/src/iosanita/contenttypes/profiles/default/rolemap.xml
index 3647c74..b15e947 100644
--- a/src/iosanita/contenttypes/profiles/default/rolemap.xml
+++ b/src/iosanita/contenttypes/profiles/default/rolemap.xml
@@ -59,5 +59,11 @@
+
+
+
+
+
+
diff --git a/src/iosanita/contenttypes/profiles/default/types.xml b/src/iosanita/contenttypes/profiles/default/types.xml
index bc925a3..1a06490 100644
--- a/src/iosanita/contenttypes/profiles/default/types.xml
+++ b/src/iosanita/contenttypes/profiles/default/types.xml
@@ -22,5 +22,6 @@
name="Struttura"
/>
+
diff --git a/src/iosanita/contenttypes/profiles/default/types/Documento.xml b/src/iosanita/contenttypes/profiles/default/types/Documento.xml
new file mode 100644
index 0000000..3e2b046
--- /dev/null
+++ b/src/iosanita/contenttypes/profiles/default/types/Documento.xml
@@ -0,0 +1,108 @@
+
+
diff --git a/src/iosanita/contenttypes/restapi/services/types/get.py b/src/iosanita/contenttypes/restapi/services/types/get.py
index d70d9c3..6edb6aa 100644
--- a/src/iosanita/contenttypes/restapi/services/types/get.py
+++ b/src/iosanita/contenttypes/restapi/services/types/get.py
@@ -24,6 +24,11 @@ class FieldsetsMismatchError(Exception):
"utenti",
"ulteriori_informazioni",
],
+ "Documento": [
+ "default",
+ "cosa_e",
+ "a_chi_si_rivolge",
+ ],
"Event": [
"default",
"cosa_e",
diff --git a/src/iosanita/contenttypes/tests/test_ct_documento.py b/src/iosanita/contenttypes/tests/test_ct_documento.py
new file mode 100644
index 0000000..4d8f5b1
--- /dev/null
+++ b/src/iosanita/contenttypes/tests/test_ct_documento.py
@@ -0,0 +1,124 @@
+# -*- coding: utf-8 -*-
+"""Setup tests for this package."""
+from iosanita.contenttypes.testing import RESTAPI_TESTING
+from plone import api
+from plone.app.testing import setRoles
+from plone.app.testing import SITE_OWNER_NAME
+from plone.app.testing import SITE_OWNER_PASSWORD
+from plone.app.testing import TEST_USER_ID
+from plone.restapi.testing import RelativeSession
+
+import unittest
+
+
+class TestDocumentoSchema(unittest.TestCase):
+ layer = RESTAPI_TESTING
+
+ def setUp(self):
+ self.app = self.layer["app"]
+ self.portal = self.layer["portal"]
+ self.request = self.layer["request"]
+ self.portal_url = self.portal.absolute_url()
+ setRoles(self.portal, TEST_USER_ID, ["Manager"])
+
+ self.api_session = RelativeSession(self.portal_url)
+ self.api_session.headers.update({"Accept": "application/json"})
+ self.api_session.auth = (SITE_OWNER_NAME, SITE_OWNER_PASSWORD)
+
+ def tearDown(self):
+ self.api_session.close()
+
+ def test_behaviors_enabled_for_documento(self):
+ portal_types = api.portal.get_tool(name="portal_types")
+ self.assertEqual(
+ portal_types["Documento"].behaviors,
+ (
+ "plone.namefromtitle",
+ "plone.allowdiscussion",
+ "plone.excludefromnavigation",
+ "plone.shortname",
+ "plone.ownership",
+ "plone.publication",
+ "plone.categorization",
+ "plone.basic",
+ "plone.locking",
+ "plone.constraintypes",
+ "plone.leadimage",
+ "volto.preview_image",
+ "plone.relateditems",
+ "plone.textindexer",
+ "plone.translatable",
+ "kitconcept.seo",
+ "plone.versioning",
+ "iosanita.contenttypes.behavior.a_chi_si_rivolge",
+ "collective.taxonomy.generated.a_chi_si_rivolge_tassonomia",
+ "collective.taxonomy.generated.parliamo_di",
+ ),
+ )
+
+ def test_documento_fieldsets(self):
+ """
+ Get the list from restapi
+ """
+ resp = self.api_session.get("@types/Documento").json()
+ self.assertEqual(len(resp["fieldsets"]), 8)
+ self.assertEqual(
+ [x.get("id") for x in resp["fieldsets"]],
+ [
+ "default",
+ "cosa_e",
+ "a_chi_si_rivolge",
+ "settings",
+ "ownership",
+ "dates",
+ "categorization",
+ "seo",
+ ],
+ )
+
+ def test_documento_required_fields(self):
+ resp = self.api_session.get("@types/Documento").json()
+ self.assertEqual(
+ sorted(resp["required"]),
+ sorted(
+ [
+ "title",
+ "descrizione_estesa",
+ "uo_correlata",
+ # "description", is required from schema_tweaks.py but it doesn't apply in test
+ ]
+ ),
+ )
+
+ def test_documento_fields_default_fieldset(self):
+ """
+ Get the list from restapi
+ """
+ resp = self.api_session.get("@types/Documento").json()
+ self.assertEqual(
+ resp["fieldsets"][0]["fields"],
+ [
+ "title",
+ "description",
+ "protocollo",
+ "data_protocollo",
+ "servizio_procedura_riferimento",
+ "uo_correlata",
+ "autori",
+ "image",
+ "image_caption",
+ "preview_image",
+ "preview_caption",
+ "parliamo_di",
+ ],
+ )
+
+ def test_documento_fields_a_chi_si_rivolge_fieldset(self):
+ """
+ Get the list from restapi
+ """
+ resp = self.api_session.get("@types/Documento").json()
+ self.assertEqual(
+ resp["fieldsets"][2]["fields"],
+ ["a_chi_si_rivolge", "a_chi_si_rivolge_tassonomia"],
+ )