Skip to content

Commit 1bfdba4

Browse files
cekkmamico
andauthored
Code improvements (#247)
* improved tests * make package more extensible * Do not show fieldsets with no visible fields in @types endpoint. * lower log level * fix test * Add getObjSize info in File field serializer * add collective.volto.enhancedlinks dependency (needed for slate integration) * initial work * remove customizations * Add new flag in settings needed to choose to show or not auto-generated footer columns and Customize @navigation endpoint to expose also the new flag for frontend * zpretty * update readme * add info also for image fields * fix imports * enhance Bandi serializer for enhancedlinks features * fix check * Fix in @scadenziario endpoint: return future events if afterToday criteria is set * fix upgrade-steps * removed unused logger * fix tests * standardize subfolders creation in events * update changelog * zpretty --------- Co-authored-by: Mauro Amico <[email protected]>
1 parent 96a9e8a commit 1bfdba4

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+2515
-712
lines changed

CHANGES.rst

+8-3
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,14 @@ Changelog
44
6.1.15 (unreleased)
55
-------------------
66

7-
- Nothing changed yet.
8-
7+
- Remove unused behavior (design.plone.contenttypes.behavior.geolocation_uo).
8+
[cekk]
9+
- Standardize subfolders creations in events.
10+
[cekk]
11+
- Do not return a fieldset if it has all fields hidden (maybe after a schema tweak).
12+
[cekk]
13+
- Improve types test for their schema, required fields, fieldsets.
14+
[cekk]
915

1016
6.1.14 (2024-02-20)
1117
-------------------
@@ -19,7 +25,6 @@ Changelog
1925
[eikichi18]
2026

2127

22-
2328
6.1.13 (2024-02-08)
2429
-------------------
2530

base.cfg

+1
Original file line numberDiff line numberDiff line change
@@ -143,3 +143,4 @@ design.plone.contenttypes =
143143
#redturtle.volto = git https://github.com/RedTurtle/redturtle.volto.git [email protected]:RedTurtle/redturtle.volto.git
144144
#redturtle.bandi = git https://github.com/RedTurtle/redturtle.bandi.git [email protected]:RedTurtle/redturtle.bandi.git
145145
#plone.restapi = git https://github.com/plone/plone.restapi.git
146+
collective.volto.enhancedlinks = git https://github.com/RegioneER/collective.volto.enhancedlinks.git pushurl[email protected]:RegioneER/collective.volto.enhancedlinks.git branch=main

setup.py

+1
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@
6666
"z3c.unconfigure",
6767
"eea.api.taxonomy",
6868
"openpyxl",
69+
"collective.volto.enhancedlinks",
6970
],
7071
extras_require={
7172
"test": [

src/design/plone/contenttypes/adapters/configure.zcml

+1
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,5 @@
2020
factory=".searchabletext_indexers.TextBlockSearchableText"
2121
name="text"
2222
/>
23+
2324
</configure>

src/design/plone/contenttypes/behaviors/configure.zcml

-8
Original file line numberDiff line numberDiff line change
@@ -261,14 +261,6 @@
261261
provides=".contatti.IContattiEvent"
262262
marker=".contatti.IContattiEvent"
263263
/>
264-
<plone:behavior
265-
name="design.plone.contenttypes.behavior.geolocation_uo"
266-
title="Geolocatable"
267-
description="Behavior geolocatable per UO."
268-
factory=".geolocation.GeolocatableUnitaOrganizzativa"
269-
provides=".geolocation.IGeolocatableUnitaOrganizzativa"
270-
marker=".geolocation.IGeolocatableUnitaOrganizzativa"
271-
/>
272264
<plone:behavior
273265
name="design.plone.contenttypes.behavior.geolocation_venue"
274266
title="Geolocatable"

src/design/plone/contenttypes/events/bando.py

-19
This file was deleted.

src/design/plone/contenttypes/events/common.py

+169
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,142 @@
11
# -*- coding: utf-8 -*-
2+
from design.plone.contenttypes.interfaces import IDesignPloneContenttypesLayer
3+
from design.plone.contenttypes.utils import create_default_blocks
4+
from plone import api
5+
from Products.CMFPlone.interfaces import ISelectableConstrainTypes
6+
7+
8+
SUBFOLDERS_MAPPING = {
9+
"Bando": [
10+
{"id": "documenti", "title": "Documenti", "type": "Bando Folder Deepening"},
11+
{
12+
"id": "comunicazioni",
13+
"title": "Comunicazioni",
14+
"type": "Bando Folder Deepening",
15+
},
16+
{"id": "esiti", "title": "Esiti", "type": "Bando Folder Deepening"},
17+
],
18+
"Documento": [
19+
{
20+
"id": "multimedia",
21+
"title": "Multimedia",
22+
"type": "Document",
23+
"allowed_types": ("Image",),
24+
},
25+
],
26+
"Event": [
27+
{
28+
"id": "immagini",
29+
"title": "Immagini",
30+
"allowed_types": ("Image", "Link"),
31+
"publish": True,
32+
},
33+
{
34+
"id": "video",
35+
"title": "Video",
36+
"allowed_types": ("Link",),
37+
"publish": True,
38+
},
39+
{
40+
"id": "sponsor_evento",
41+
"title": "Sponsor Evento",
42+
"allowed_types": ("Link",),
43+
"publish": True,
44+
},
45+
{
46+
"id": "documenti",
47+
"title": "Allegati",
48+
"allowed_types": ("File",),
49+
"publish": True,
50+
},
51+
],
52+
"Incarico": [
53+
{"id": "compensi-file", "title": "Compensi", "allowed": ("File",)},
54+
{
55+
"id": "importi-di-viaggio-e-o-servizi",
56+
"title": "Importi di viaggio e/o servizi",
57+
"allowed_types": ("File",),
58+
},
59+
],
60+
"Venue": [
61+
{
62+
"id": "multimedia",
63+
"title": "Multimedia",
64+
"type": "Folder",
65+
"allowed_types": (
66+
"Image",
67+
"Link",
68+
),
69+
"publish": True,
70+
}
71+
],
72+
"News Item": [
73+
{
74+
"id": "multimedia",
75+
"title": "Multimedia",
76+
"allowed_types": (
77+
"Image",
78+
"Link",
79+
),
80+
},
81+
{
82+
"id": "documenti-allegati",
83+
"title": "Documenti allegati",
84+
"allowed_types": (
85+
"File",
86+
"Image",
87+
),
88+
},
89+
],
90+
"Persona": [
91+
{
92+
"id": "foto-e-attivita-politica",
93+
"title": "Foto e attività politica",
94+
"allowed_types": ("Image",),
95+
},
96+
{
97+
"id": "curriculum-vitae",
98+
"title": "Curriculum vitae",
99+
"allowed_types": ("File",),
100+
},
101+
{
102+
"id": "situazione-patrimoniale",
103+
"title": "Situazione patrimoniale",
104+
"allowed_types": ("File",),
105+
},
106+
{
107+
"id": "dichiarazione-dei-redditi",
108+
"title": "Dichiarazione dei redditi",
109+
"allowed_types": ("File",),
110+
},
111+
{
112+
"id": "spese-elettorali",
113+
"title": "Spese elettorali",
114+
"allowed_types": ("File",),
115+
},
116+
{
117+
"id": "variazione-situazione-patrimoniale",
118+
"title": "Variazione situazione patrimoniale",
119+
"allowed_types": ("File",),
120+
},
121+
{"id": "altre-cariche", "title": "Altre cariche", "allowed_types": ("File",)},
122+
{"id": "incarichi", "title": "Incarichi", "allowed_types": ("Incarico",)},
123+
],
124+
"Pratica": [
125+
{
126+
"id": "allegati",
127+
"title": "Allegati",
128+
"type": "Folder",
129+
"allowed_types": ("File",),
130+
}
131+
],
132+
"Servizio": [
133+
{"id": "modulistica", "title": "Modulistica", "contains": ("File", "Link")},
134+
{"id": "allegati", "title": "Allegati", "contains": ("File", "Link")},
135+
],
136+
"UnitaOrganizzativa": [
137+
{"id": "allegati", "title": "Allegati", "contains": ("File",)},
138+
],
139+
}
2140

3141

4142
def onModify(context, event):
@@ -8,3 +146,34 @@ def onModify(context, event):
8146
) or "IDublinCore.title" in getattr(description, "attributes", []):
9147
for child in context.listFolderContents():
10148
child.reindexObject(idxs=["parent"])
149+
150+
151+
def createSubfolders(context, event):
152+
"""
153+
Create subfolders structure based on a portal_type mapping
154+
"""
155+
if not IDesignPloneContenttypesLayer.providedBy(context.REQUEST):
156+
return
157+
158+
subfolders_mapping = SUBFOLDERS_MAPPING.get(context.portal_type, [])
159+
if not subfolders_mapping:
160+
return
161+
for mapping in subfolders_mapping:
162+
if mapping["id"] not in context.keys():
163+
child = api.content.create(
164+
container=context,
165+
type=mapping.get("type", "Document"),
166+
title=mapping["title"],
167+
id=mapping["id"],
168+
)
169+
create_default_blocks(context=child)
170+
171+
# select constraints
172+
if mapping.get("allowed_types", ()):
173+
constraintsChild = ISelectableConstrainTypes(child)
174+
constraintsChild.setConstrainTypesMode(1)
175+
constraintsChild.setLocallyAllowedTypes(mapping["allowed_types"])
176+
177+
if mapping.get("publish", False):
178+
with api.env.adopt_roles(["Reviewer"]):
179+
api.content.transition(obj=child, transition="publish")

src/design/plone/contenttypes/events/configure.zcml

+5-51
Original file line numberDiff line numberDiff line change
@@ -5,46 +5,6 @@
55
i18n_domain="design.plone.contenttypes"
66
>
77

8-
<subscriber
9-
for="design.plone.contenttypes.interfaces.pratica.IPratica
10-
zope.lifecycleevent.interfaces.IObjectAddedEvent"
11-
handler=".pratica.praticaCreateHandler"
12-
/>
13-
<subscriber
14-
for="collective.venue.interfaces.IVenue
15-
zope.lifecycleevent.interfaces.IObjectAddedEvent"
16-
handler=".luogo.luogoCreateHandler"
17-
/>
18-
<subscriber
19-
for="design.plone.contenttypes.interfaces.unita_organizzativa.IUnitaOrganizzativa
20-
zope.lifecycleevent.interfaces.IObjectAddedEvent"
21-
handler=".unita_organizzativa.unitaOrganizzativaCreateHandler"
22-
/>
23-
<subscriber
24-
for="design.plone.contenttypes.interfaces.persona.IPersona
25-
zope.lifecycleevent.interfaces.IObjectAddedEvent"
26-
handler=".persona.personaCreateHandler"
27-
/>
28-
<subscriber
29-
for="plone.event.interfaces.IEvent
30-
zope.lifecycleevent.interfaces.IObjectAddedEvent"
31-
handler=".evento.eventoCreateHandler"
32-
/>
33-
<subscriber
34-
for="design.plone.contenttypes.interfaces.documento.IDocumento
35-
zope.lifecycleevent.interfaces.IObjectAddedEvent"
36-
handler=".documento.documentoCreateHandler"
37-
/>
38-
<subscriber
39-
for="design.plone.contenttypes.interfaces.servizio.IServizio
40-
zope.lifecycleevent.interfaces.IObjectAddedEvent"
41-
handler=".servizio.servizioCreateHandler"
42-
/>
43-
<subscriber
44-
for="plone.app.contenttypes.interfaces.INewsItem
45-
zope.lifecycleevent.interfaces.IObjectAddedEvent"
46-
handler=".notizie_e_comunicati_stampa.notiziaCreateHandler"
47-
/>
488
<subscriber
499
for="design.plone.contenttypes.interfaces.pagina_argomento.IPaginaArgomento
5010
zope.lifecycleevent.interfaces.IObjectModifiedEvent"
@@ -55,16 +15,6 @@
5515
zope.lifecycleevent.interfaces.IObjectAddedEvent"
5616
handler=".document.documentCreateHandler"
5717
/>
58-
<subscriber
59-
for="redturtle.bandi.interfaces.bando.IBando
60-
zope.lifecycleevent.interfaces.IObjectAddedEvent"
61-
handler=".bando.bandoCreateHandler"
62-
/>
63-
<subscriber
64-
for="design.plone.contenttypes.interfaces.incarico.IIncarico
65-
zope.lifecycleevent.interfaces.IObjectAddedEvent"
66-
handler=".incarico.incaricoCreateHandler"
67-
/>
6818
<subscriber
6919
for="design.plone.contenttypes.interfaces.incarico.IIncarico
7020
zope.lifecycleevent.interfaces.IObjectModifiedEvent"
@@ -76,5 +26,9 @@
7626
zope.lifecycleevent.interfaces.IObjectModifiedEvent"
7727
handler=".common.onModify"
7828
/>
79-
29+
<subscriber
30+
for="plone.dexterity.interfaces.IDexterityContent
31+
zope.lifecycleevent.interfaces.IObjectAddedEvent"
32+
handler=".common.createSubfolders"
33+
/>
8034
</configure>

src/design/plone/contenttypes/events/documento.py

-36
This file was deleted.

0 commit comments

Comments
 (0)