Skip to content

Commit

Permalink
remove file from addable types in servizio/modulistica folder
Browse files Browse the repository at this point in the history
  • Loading branch information
luca-bellenghi committed Jun 11, 2024
1 parent 153cee8 commit 1fc7ebd
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 7 deletions.
10 changes: 6 additions & 4 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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)
------------------
Expand All @@ -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)
------------------
Expand Down
2 changes: 1 addition & 1 deletion src/design/plone/contenttypes/events/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@
{
"id": "modulistica",
"title": "Modulistica",
"allowed_types": ("File", "Link"),
"allowed_types": ("Link",),
},
{"id": "allegati", "title": "Allegati", "allowed_types": ("File", "Link")},
],
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<metadata>
<version>7304</version>
<version>7305</version>
<dependencies>
<dependency>profile-redturtle.bandi:default</dependency>
<dependency>profile-collective.venue:default</dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
7 changes: 7 additions & 0 deletions src/design/plone/contenttypes/upgrades/configure.zcml
Original file line number Diff line number Diff line change
Expand Up @@ -884,5 +884,12 @@
destination="7304"
handler=".to_730x.to_7304"
/>
<genericsetup:upgradeStep
title="Reindex an index to update catalog values"
profile="design.plone.contenttypes:default"
source="7304"
destination="7354"
handler=".to_730x.to_7305"
/>

</configure>
22 changes: 22 additions & 0 deletions src/design/plone/contenttypes/upgrades/to_730x.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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"])

0 comments on commit 1fc7ebd

Please sign in to comment.