diff --git a/CHANGES.rst b/CHANGES.rst index 54faef56..9910347b 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -4,7 +4,8 @@ Changelog 6.2.9 (unreleased) ------------------ -- Nothing changed yet. +- Aggiunto la cartella "Altri Documenti" sulla persona + [lucabel] 6.2.8 (2024-04-22) diff --git a/setup.py b/setup.py index 7a6a7378..ada821bd 100644 --- a/setup.py +++ b/setup.py @@ -64,6 +64,7 @@ "redturtle.volto>=5.0.0", "redturtle.bandi", "z3c.unconfigure", + "plone.restapi<9.6.1", "eea.api.taxonomy", "openpyxl", "collective.volto.enhancedlinks", diff --git a/src/design/plone/contenttypes/events/common.py b/src/design/plone/contenttypes/events/common.py index 9295226a..44475c88 100644 --- a/src/design/plone/contenttypes/events/common.py +++ b/src/design/plone/contenttypes/events/common.py @@ -120,6 +120,11 @@ }, {"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"), + }, ], "Pratica": [ { diff --git a/src/design/plone/contenttypes/profiles/default/metadata.xml b/src/design/plone/contenttypes/profiles/default/metadata.xml index 66b31642..6009331a 100644 --- a/src/design/plone/contenttypes/profiles/default/metadata.xml +++ b/src/design/plone/contenttypes/profiles/default/metadata.xml @@ -1,6 +1,6 @@ - 7300 + 7301 profile-redturtle.bandi:default profile-collective.venue:default diff --git a/src/design/plone/contenttypes/restapi/serializers/summary.py b/src/design/plone/contenttypes/restapi/serializers/summary.py index 5e5d98d0..ac587ef2 100644 --- a/src/design/plone/contenttypes/restapi/serializers/summary.py +++ b/src/design/plone/contenttypes/restapi/serializers/summary.py @@ -183,7 +183,6 @@ def __call__(self, force_all_metadata=False, force_images=False): if self.is_get_call(): res["has_children"] = self.has_children() - if force_images: # TODO: verificare se non c'è il campo o se il campo è null/vuoto ? if not res.get("image_scales") and not res.get("image_field"): @@ -198,7 +197,14 @@ def __call__(self, force_all_metadata=False, force_images=False): res["image_field"] = "preview_image" elif "image" in scales: res["image_field"] = "image" - + # plone.app.contentlisting 3.0.5 sembra fissare un accessor che ci + # fa arrivare uno scale senza image_field. + # avremmo questo problema una volta passati a plone 6.0.11 + elif res.get("image_scales") and not res.get("image_field"): + if "preview_image" in res["image_scales"]: + res["image_field"] = "preview_image" + elif "image" in res["image_scales"]: + res["image_field"] = "image" return res def has_children(self): diff --git a/src/design/plone/contenttypes/tests/test_substructure_creation.py b/src/design/plone/contenttypes/tests/test_substructure_creation.py index 991bc753..4147ac43 100644 --- a/src/design/plone/contenttypes/tests/test_substructure_creation.py +++ b/src/design/plone/contenttypes/tests/test_substructure_creation.py @@ -221,6 +221,7 @@ def test_persona_substructure_created(self): - spese-elettorali - variazione-situazione-patrimoniale" "altre-cariche - incarichi + - altri-documenti """ item = api.content.create( container=self.portal, @@ -239,6 +240,7 @@ def test_persona_substructure_created(self): "variazione-situazione-patrimoniale", "altre-cariche", "incarichi", + "altri-documenti", ], ) @@ -317,6 +319,14 @@ def test_persona_substructure_created(self): self.assertEqual(item["incarichi"].locally_allowed_types, ("Incarico",)) self.assertTrue(item["incarichi"].exclude_from_search) + self.assertEqual(item["altri-documenti"].portal_type, "Document") + self.assertEqual(api.content.get_state(item["altri-documenti"]), "private") + self.assertEqual(item["altri-documenti"].constrain_types_mode, 1) + self.assertIn("File", item["altri-documenti"].locally_allowed_types) + self.assertIn("Link", item["altri-documenti"].locally_allowed_types) + self.assertIn("Image", item["altri-documenti"].locally_allowed_types) + self.assertTrue(item["altri-documenti"].exclude_from_search) + def test_servizio_substructure_created(self): """ Should have: diff --git a/src/design/plone/contenttypes/tests/test_uo_summary_serializer.py b/src/design/plone/contenttypes/tests/test_uo_summary_serializer.py index c4108dd8..a57ed117 100644 --- a/src/design/plone/contenttypes/tests/test_uo_summary_serializer.py +++ b/src/design/plone/contenttypes/tests/test_uo_summary_serializer.py @@ -105,7 +105,11 @@ def test_image_in_uo_serializer(self): res = response.json() uo_children = res["uo_children"][0] self.assertEqual(uo_children["image_field"], None) - self.assertEqual(uo_children["image_scales"], None) + # Plone 6.0.10.1 due to a bug in plone.app.contentlisting (#64 + # from github issue) return None + # Plone 6.0.11 upgrades plone.app.contentlisting to a version + # fixing the problem and the changing the return value to {} + self.assertIn(uo_children["image_scales"], (None, {})) # now, add a preview image filename = os.path.join(os.path.dirname(__file__), "example.png") diff --git a/src/design/plone/contenttypes/upgrades/configure.zcml b/src/design/plone/contenttypes/upgrades/configure.zcml index c3b93f12..0d5f55af 100644 --- a/src/design/plone/contenttypes/upgrades/configure.zcml +++ b/src/design/plone/contenttypes/upgrades/configure.zcml @@ -856,5 +856,12 @@ destination="7300" handler=".to_7300.to_7300" /> + diff --git a/src/design/plone/contenttypes/upgrades/to_730x.py b/src/design/plone/contenttypes/upgrades/to_730x.py new file mode 100644 index 00000000..6f498d84 --- /dev/null +++ b/src/design/plone/contenttypes/upgrades/to_730x.py @@ -0,0 +1,45 @@ +# -*- coding: utf-8 -*- +from design.plone.contenttypes.utils import create_default_blocks +from plone import api +from Products.CMFPlone.interfaces import ISelectableConstrainTypes + +import logging + + +logger = logging.getLogger(__name__) + +DEFAULT_PROFILE = "profile-design.plone.contenttypes:default" + + +def to_7301(context): + brains = api.content.find(portal_type="Persona") + for brain in brains: + persona = brain.getObject() + FOLDER_ID = "altri-documenti" + if FOLDER_ID not in persona.keys(): + child = api.content.create( + container=persona, + type="Document", + title="Altri documenti", + id=FOLDER_ID, + ) + create_default_blocks(context=child) + else: + child = persona[FOLDER_ID] + + child.exclude_from_search = True + child.reindexObject(idxs=["exclude_from_search"]) + # select constraints + constraintsChild = ISelectableConstrainTypes(child) + constraintsChild.setConstrainTypesMode(1) + constraintsChild.setLocallyAllowedTypes( + ( + "File", + "Image", + "Link", + ) + ) + if api.content.get_state(persona) == "published": + if api.content.get_state(child) != "published": + with api.env.adopt_roles(["Reviewer"]): + api.content.transition(obj=child, transition="publish") diff --git a/test_plone60.cfg b/test_plone60.cfg index a0b9ce9d..59e99e0e 100644 --- a/test_plone60.cfg +++ b/test_plone60.cfg @@ -4,6 +4,7 @@ extends = https://raw.github.com/collective/buildout.plonetest/master/test-6.0.x.cfg https://raw.githubusercontent.com/collective/buildout.plonetest/master/qa.cfg https://raw.githubusercontent.com/RedTurtle/iocomune-backend/main/versions.cfg + https://dist.plone.org/release/6.0.10.1/versions.cfg base.cfg update-versions-file = test_plone60.cfg