From 1fc7ebde299ef6e9aaa270833901e6145671e9ae Mon Sep 17 00:00:00 2001 From: Luca Bellenghi Date: Tue, 11 Jun 2024 11:24:05 +0200 Subject: [PATCH] remove file from addable types in servizio/modulistica folder --- CHANGES.rst | 10 +++++---- .../plone/contenttypes/events/common.py | 2 +- .../profiles/default/metadata.xml | 2 +- .../tests/test_substructure_creation.py | 2 +- .../contenttypes/upgrades/configure.zcml | 7 ++++++ .../plone/contenttypes/upgrades/to_730x.py | 22 +++++++++++++++++++ 6 files changed, 38 insertions(+), 7 deletions(-) diff --git a/CHANGES.rst b/CHANGES.rst index 3de8e52a..96f54fc0 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -6,7 +6,12 @@ Changelog - Add importi_viaggio_servizio field as block field in Incarico response [eikichi18] - +- Add rassegna index to events + [lucabel] +- Remove File from addable type in Servizio / modulistica folder. As stated + by AGID team we can't add File in this folder but link to modules in + "Documenti e Dati" section + [lucabel] 6.2.9 (2024-05-21) ------------------ @@ -17,9 +22,6 @@ Changelog due to some core egg update Code porting to work with the new plone.restapi 9.6.1 version [lucabel] -- Add rassegna index to events - [lucabel] - 6.2.8 (2024-04-22) ------------------ diff --git a/src/design/plone/contenttypes/events/common.py b/src/design/plone/contenttypes/events/common.py index 44475c88..2f4a1a06 100644 --- a/src/design/plone/contenttypes/events/common.py +++ b/src/design/plone/contenttypes/events/common.py @@ -138,7 +138,7 @@ { "id": "modulistica", "title": "Modulistica", - "allowed_types": ("File", "Link"), + "allowed_types": ("Link",), }, {"id": "allegati", "title": "Allegati", "allowed_types": ("File", "Link")}, ], diff --git a/src/design/plone/contenttypes/profiles/default/metadata.xml b/src/design/plone/contenttypes/profiles/default/metadata.xml index c63caa09..1492c7cf 100644 --- a/src/design/plone/contenttypes/profiles/default/metadata.xml +++ b/src/design/plone/contenttypes/profiles/default/metadata.xml @@ -1,6 +1,6 @@ - 7304 + 7305 profile-redturtle.bandi:default profile-collective.venue:default diff --git a/src/design/plone/contenttypes/tests/test_substructure_creation.py b/src/design/plone/contenttypes/tests/test_substructure_creation.py index 4147ac43..1991a0dc 100644 --- a/src/design/plone/contenttypes/tests/test_substructure_creation.py +++ b/src/design/plone/contenttypes/tests/test_substructure_creation.py @@ -347,7 +347,7 @@ def test_servizio_substructure_created(self): self.assertEqual(item["modulistica"].portal_type, "Document") self.assertEqual(api.content.get_state(item["modulistica"]), "private") self.assertEqual(item["modulistica"].constrain_types_mode, 1) - self.assertEqual(item["modulistica"].locally_allowed_types, ("File", "Link")) + self.assertEqual(item["modulistica"].locally_allowed_types, ("Link",)) self.assertTrue(item["modulistica"].exclude_from_search) self.assertEqual(item["allegati"].portal_type, "Document") diff --git a/src/design/plone/contenttypes/upgrades/configure.zcml b/src/design/plone/contenttypes/upgrades/configure.zcml index 9562d151..5253bef1 100644 --- a/src/design/plone/contenttypes/upgrades/configure.zcml +++ b/src/design/plone/contenttypes/upgrades/configure.zcml @@ -884,5 +884,12 @@ destination="7304" handler=".to_730x.to_7304" /> + diff --git a/src/design/plone/contenttypes/upgrades/to_730x.py b/src/design/plone/contenttypes/upgrades/to_730x.py index a4f9a45c..e51f2547 100644 --- a/src/design/plone/contenttypes/upgrades/to_730x.py +++ b/src/design/plone/contenttypes/upgrades/to_730x.py @@ -1,5 +1,6 @@ # -*- coding: utf-8 -*- from design.plone.contenttypes.utils import create_default_blocks +from design.plone.contenttypes.events.common import SUBFOLDERS_MAPPING from plone import api from Products.CMFPlone.interfaces import ISelectableConstrainTypes import transaction @@ -86,3 +87,24 @@ def to_7304(context): transaction.commit() doc = brain.getObject() doc.reindexObject(idxs=["parent"]) + + +def to_7305(context): + mapping = SUBFOLDERS_MAPPING["Servizio"] + mapping = [folder for folder in mapping if folder["id"] == "modulistica"][0] + brains = api.content.find(portal_type="Servizio") + tot = len(brains) + i = 0 + for brain in brains: + i += 1 + if i % 100 == 0: + logger.info("Progress: {}/{}".format(i, tot)) + transaction.commit() + servizio = brain.getObject() + FOLDER_ID = "modulistica" + if FOLDER_ID not in servizio.keys(): + continue + child = servizio[FOLDER_ID] + constraintsChild = ISelectableConstrainTypes(child) + constraintsChild.setConstrainTypesMode(1) + constraintsChild.setLocallyAllowedTypes(mapping["allowed_types"])