diff --git a/src/iosanita/contenttypes/behaviors/argomenti.py b/src/iosanita/contenttypes/behaviors/argomenti.py
index 97dbb83..844c164 100644
--- a/src/iosanita/contenttypes/behaviors/argomenti.py
+++ b/src/iosanita/contenttypes/behaviors/argomenti.py
@@ -31,20 +31,6 @@ class IArgomentiSchema(model.Schema):
required=False,
default=[],
)
- correlato_in_evidenza = RelationList(
- title=_("correlato_in_evidenza_label", default="Correlato in evidenza"),
- description=_(
- "correlato_in_evidenza_help",
- default="Seleziona un correlato da mettere in evidenza per questo"
- " contenuto.",
- ),
- value_type=RelationChoice(
- title=_("Correlato in evidenza"),
- vocabulary="plone.app.vocabularies.Catalog",
- ),
- required=False,
- default=[],
- )
form.widget(
"tassonomia_argomenti",
@@ -54,12 +40,6 @@ class IArgomentiSchema(model.Schema):
"selectableTypes": ["Pagina Argomento"],
},
)
- form.widget(
- "correlato_in_evidenza",
- RelatedItemsFieldWidget,
- vocabulary="plone.app.vocabularies.Catalog",
- pattern_options={"maximumSelectionSize": 1},
- )
textindexer.searchable("tassonomia_argomenti")
@@ -68,12 +48,6 @@ class IArgomentiSchema(model.Schema):
class IArgomenti(IArgomentiSchema):
""" """
- model.fieldset(
- "correlati",
- label=_("correlati_label", default="Contenuti collegati"),
- fields=["correlato_in_evidenza"],
- )
-
@provider(IFormFieldProvider)
class IArgomentiEvento(IArgomentiSchema):
diff --git a/src/iosanita/contenttypes/events/__init__.py b/src/iosanita/contenttypes/events/__init__.py
new file mode 100644
index 0000000..e69de29
diff --git a/src/iosanita/contenttypes/events/common.py b/src/iosanita/contenttypes/events/common.py
new file mode 100644
index 0000000..70d69fb
--- /dev/null
+++ b/src/iosanita/contenttypes/events/common.py
@@ -0,0 +1,229 @@
+# -*- coding: utf-8 -*-
+from design.plone.contenttypes.interfaces import IDesignPloneContenttypesLayer
+from design.plone.contenttypes.utils import create_default_blocks
+from plone import api
+from Products.CMFPlone.interfaces import ISelectableConstrainTypes
+
+
+SUBFOLDERS_MAPPING = {
+ "Bando": {
+ "content": [
+ {"id": "documenti", "title": "Documenti", "type": "Bando Folder Deepening"},
+ {
+ "id": "comunicazioni",
+ "title": "Comunicazioni",
+ "type": "Bando Folder Deepening",
+ },
+ {"id": "esiti", "title": "Esiti", "type": "Bando Folder Deepening"},
+ ],
+ },
+ "Documento": {
+ "content": [
+ {
+ "id": "multimedia",
+ "title": "Multimedia",
+ "type": "Document",
+ "allowed_types": ("Image",),
+ },
+ ],
+ },
+ "Event": {
+ "content": [
+ {
+ "id": "immagini",
+ "title": "Immagini",
+ "allowed_types": ("Image", "Link"),
+ "publish": True,
+ },
+ {
+ "id": "video",
+ "title": "Video",
+ "allowed_types": ("Link",),
+ "publish": True,
+ },
+ {
+ "id": "sponsor_evento",
+ "title": "Sponsor Evento",
+ "allowed_types": ("Link",),
+ "publish": True,
+ },
+ {
+ "id": "documenti",
+ "title": "Allegati",
+ "allowed_types": ("File",),
+ "publish": True,
+ },
+ ],
+ },
+ "Incarico": {
+ "content": [
+ {"id": "compensi-file", "title": "Compensi", "allowed": ("File",)},
+ {
+ "id": "importi-di-viaggio-e-o-servizi",
+ "title": "Importi di viaggio e/o servizi",
+ "allowed_types": ("File",),
+ },
+ ],
+ "allowed_types": [],
+ },
+ "Venue": {
+ "content": [
+ {
+ "id": "multimedia",
+ "title": "Multimedia",
+ "type": "Folder",
+ "allowed_types": (
+ "Image",
+ "Link",
+ ),
+ "publish": True,
+ }
+ ],
+ },
+ "News Item": {
+ "content": [
+ {
+ "id": "multimedia",
+ "title": "Multimedia",
+ "allowed_types": (
+ "Image",
+ "Link",
+ ),
+ },
+ {
+ "id": "documenti-allegati",
+ "title": "Documenti allegati",
+ "allowed_types": (
+ "File",
+ "Image",
+ ),
+ },
+ ],
+ },
+ "Persona": {
+ "content": [
+ {
+ "id": "foto-e-attivita-politica",
+ "title": "Foto e attività politica",
+ "allowed_types": ("Image",),
+ },
+ {
+ "id": "curriculum-vitae",
+ "title": "Curriculum vitae",
+ "allowed_types": ("File",),
+ },
+ {
+ "id": "situazione-patrimoniale",
+ "title": "Situazione patrimoniale",
+ "allowed_types": ("File",),
+ },
+ {
+ "id": "dichiarazione-dei-redditi",
+ "title": "Dichiarazione dei redditi",
+ "allowed_types": ("File",),
+ },
+ {
+ "id": "spese-elettorali",
+ "title": "Spese elettorali",
+ "allowed_types": ("File",),
+ },
+ {
+ "id": "variazione-situazione-patrimoniale",
+ "title": "Variazione situazione patrimoniale",
+ "allowed_types": ("File",),
+ },
+ {
+ "id": "altre-cariche",
+ "title": "Altre cariche",
+ "allowed_types": ("File",),
+ },
+ {"id": "incarichi", "title": "Incarichi", "allowed_types": ("Incarico",)},
+ {
+ "id": "altri-documenti",
+ "title": "Altri documenti",
+ "allowed_types": ("File", "Image", "Link"),
+ },
+ ],
+ "allowed_types": [],
+ },
+ "Pratica": {
+ "content": [
+ {
+ "id": "allegati",
+ "title": "Allegati",
+ "type": "Folder",
+ "allowed_types": ("File",),
+ }
+ ],
+ },
+ "Servizio": {
+ "content": [
+ {
+ "id": "modulistica",
+ "title": "Modulistica",
+ "allowed_types": ("Link",),
+ },
+ {"id": "allegati", "title": "Allegati", "allowed_types": ("File", "Link")},
+ ],
+ },
+ "UnitaOrganizzativa": {
+ "content": [
+ {"id": "allegati", "title": "Allegati", "allowed_types": ("File",)},
+ ],
+ },
+}
+
+
+def onModify(context, event):
+ for description in event.descriptions:
+ if "IBasic.title" in getattr(
+ description, "attributes", []
+ ) or "IDublinCore.title" in getattr(description, "attributes", []):
+ for child in context.listFolderContents():
+ child.reindexObject(idxs=["parent"])
+
+
+def createSubfolders(context, event):
+ """
+ Create subfolders structure based on a portal_type mapping
+ """
+ if not IDesignPloneContenttypesLayer.providedBy(context.REQUEST):
+ return
+
+ subfolders_mapping = SUBFOLDERS_MAPPING.get(context.portal_type, [])
+ if not subfolders_mapping:
+ return
+
+ for mapping in subfolders_mapping.get("content", {}):
+ if mapping["id"] not in context.keys():
+ portal_type = mapping.get("type", "Document")
+ child = api.content.create(
+ container=context,
+ type=portal_type,
+ title=mapping["title"],
+ id=mapping["id"],
+ )
+ if portal_type == "Document":
+ create_default_blocks(context=child)
+
+ if portal_type in ["Folder", "Document"]:
+ child.exclude_from_search = True
+ child.reindexObject(idxs=["exclude_from_search"])
+ # select constraints
+ if mapping.get("allowed_types", ()):
+ constraints_child = ISelectableConstrainTypes(child)
+ constraints_child.setConstrainTypesMode(1)
+ constraints_child.setLocallyAllowedTypes(mapping["allowed_types"])
+
+ if mapping.get("publish", False):
+ with api.env.adopt_roles(["Reviewer"]):
+ api.content.transition(obj=child, transition="publish")
+
+ allowed_types = subfolders_mapping.get("allowed_types", None)
+ if allowed_types is not None and not isinstance(allowed_types, list):
+ raise ValueError("Subfolder map is not well formed")
+
+ if isinstance(allowed_types, list):
+ constraints_context = ISelectableConstrainTypes(context)
+ constraints_context.setConstrainTypesMode(1)
+ constraints_context.setLocallyAllowedTypes(allowed_types)
diff --git a/src/iosanita/contenttypes/events/configure.zcml b/src/iosanita/contenttypes/events/configure.zcml
new file mode 100644
index 0000000..4eef01c
--- /dev/null
+++ b/src/iosanita/contenttypes/events/configure.zcml
@@ -0,0 +1,25 @@
+
+
+
+
+
+
+
+
diff --git a/src/iosanita/contenttypes/events/events.py b/src/iosanita/contenttypes/events/events.py
new file mode 100644
index 0000000..1afaab7
--- /dev/null
+++ b/src/iosanita/contenttypes/events/events.py
@@ -0,0 +1,8 @@
+from Acquisition import aq_inner, aq_parent
+
+
+def EventModified(dx_event, event):
+ parent = aq_parent(aq_inner(dx_event))
+ if parent.portal_type == "Event":
+ parent.reindexObject(idxs=["rassegna"])
+ return
diff --git a/src/iosanita/contenttypes/indexers/__init__.py b/src/iosanita/contenttypes/indexers/__init__.py
new file mode 100644
index 0000000..e69de29
diff --git a/src/iosanita/contenttypes/indexers/common.py b/src/iosanita/contenttypes/indexers/common.py
new file mode 100644
index 0000000..327f7a5
--- /dev/null
+++ b/src/iosanita/contenttypes/indexers/common.py
@@ -0,0 +1,43 @@
+# -*- coding: utf-8 -*-
+from plone.dexterity.interfaces import IDexterityContent
+from plone.indexer.decorator import indexer
+
+
+@indexer(IDexterityContent)
+def tassonomia_argomenti(context, **kw):
+ return [
+ x.to_object.Title()
+ for x in getattr(context.aq_base, "tassonomia_argomenti", [])
+ if x.to_object
+ ]
+
+
+@indexer(IDexterityContent)
+def tassonomia_argomenti_uid(context, **kw):
+ return [
+ x.to_object.UID()
+ for x in getattr(context.aq_base, "tassonomia_argomenti", [])
+ if x.to_object
+ ]
+
+
+@indexer(IDexterityContent)
+def ufficio_responsabile(context, **kw):
+ uffici = getattr(context.aq_base, "ufficio_responsabile", [])
+ return [ufficio.UID() for ufficio in filter(bool, [x.to_object for x in uffici])]
+
+
+@indexer(IDexterityContent)
+def parent(context):
+ obj_parent = context.aq_parent
+ return {
+ "title": obj_parent.Title(),
+ "UID": obj_parent.UID(),
+ "@id": obj_parent.absolute_url(),
+ "@type": obj_parent.portal_type,
+ }
+
+
+@indexer(IDexterityContent)
+def exclude_from_search(context):
+ return getattr(context.aq_base, "exclude_from_search", False)
diff --git a/src/iosanita/contenttypes/indexers/configure.zcml b/src/iosanita/contenttypes/indexers/configure.zcml
new file mode 100644
index 0000000..b63eea2
--- /dev/null
+++ b/src/iosanita/contenttypes/indexers/configure.zcml
@@ -0,0 +1,34 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/iosanita/contenttypes/indexers/events.py b/src/iosanita/contenttypes/indexers/events.py
new file mode 100644
index 0000000..6a22cb4
--- /dev/null
+++ b/src/iosanita/contenttypes/indexers/events.py
@@ -0,0 +1,19 @@
+# -*- coding: utf-8 -*-
+from plone.app.contenttypes.interfaces import IEvent
+from plone.indexer.decorator import indexer
+
+
+@indexer(IEvent)
+def event_location(context, **kw):
+ """ """
+ strutture_correlate = [x.to_object for x in context.strutture_correlate]
+ strutture_correlate = filter(bool, strutture_correlate)
+ strutture_correlate_title = [x.UID() for x in strutture_correlate]
+ return strutture_correlate_title
+
+
+@indexer(IEvent)
+def rassegna(context, **kw):
+ """ """
+ children = context.values()
+ return "Event" in [child.portal_type for child in children]
diff --git a/src/iosanita/contenttypes/indexers/news.py b/src/iosanita/contenttypes/indexers/news.py
new file mode 100644
index 0000000..d3d8a75
--- /dev/null
+++ b/src/iosanita/contenttypes/indexers/news.py
@@ -0,0 +1,32 @@
+# -*- coding: utf-8 -*-
+from plone.app.contenttypes.interfaces import INewsItem
+from plone.indexer.decorator import indexer
+
+
+@indexer(INewsItem)
+def news_people(context, **kw):
+ people = context.a_cura_di_persone
+ return [persona.UID() for persona in filter(bool, [x.to_object for x in people])]
+
+
+@indexer(INewsItem)
+def news_uo(context, **kw):
+ unita_organizzative = context.a_cura_di
+ return [
+ unita_organizzativa.UID()
+ for unita_organizzativa in filter(
+ bool, [x.to_object for x in unita_organizzative]
+ )
+ ]
+
+
+@indexer(INewsItem)
+def news_service(context, **kw):
+ servizi = context.servizi_correlati
+ return [servizio.UID() for servizio in filter(bool, [x.to_object for x in servizi])]
+
+
+@indexer(INewsItem)
+def news_venue(context, **kw):
+ luoghi = context.luoghi_correlati
+ return [luogo.UID() for luogo in filter(bool, [x.to_object for x in luoghi])]
diff --git a/src/iosanita/contenttypes/profiles/default/catalog.xml b/src/iosanita/contenttypes/profiles/default/catalog.xml
index 0685c9d..9354784 100644
--- a/src/iosanita/contenttypes/profiles/default/catalog.xml
+++ b/src/iosanita/contenttypes/profiles/default/catalog.xml
@@ -1,4 +1,29 @@
-
-