Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Code improvements #247

Merged
merged 38 commits into from
Mar 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
cea20d6
improved tests
cekk Oct 13, 2023
3ad0dae
make package more extensible
cekk Oct 16, 2023
27ab421
Do not show fieldsets with no visible fields in @types endpoint.
cekk Oct 24, 2023
6eb94bc
lower log level
cekk Oct 25, 2023
d2e5acd
Merge branch 'main' into v2v3_test
cekk Nov 7, 2023
43e74fa
fix test
cekk Nov 7, 2023
d5abe98
Add getObjSize info in File field serializer
cekk Jan 25, 2024
f14babd
add collective.volto.enhancedlinks dependency (needed for slate integ…
cekk Jan 26, 2024
08d5bac
initial work
cekk Jan 26, 2024
d8fb433
Merge branch 'main' into add_getobjsize_info_in_serializer
cekk Jan 26, 2024
fa4cf9f
remove customizations
cekk Jan 26, 2024
8a55b80
Merge branch 'main' into add_getobjsize_info_in_serializer
mamico Jan 26, 2024
e2206dd
Add new flag in settings needed to choose to show or not auto-generat…
cekk Jan 27, 2024
9a01432
zpretty
cekk Jan 27, 2024
9dd91ea
update readme
cekk Jan 27, 2024
eb4ebc3
Merge branch 'main' into v2v3_test
cekk Jan 29, 2024
2f564e0
Merge remote-tracking branch 'origin/add_getobjsize_info_in_serialize…
cekk Jan 29, 2024
9c39869
add info also for image fields
cekk Jan 29, 2024
fae8de8
Merge branch 'add_getobjsize_info_in_serializer' of github.com:RedTur…
cekk Jan 29, 2024
d21a2a2
Merge branch 'add_getobjsize_info_in_serializer' into v2v3_test
cekk Jan 29, 2024
460bc1f
Merge branch 'v2v3_test' of github.com:RedTurtle/design.plone.content…
cekk Jan 29, 2024
6d5fbff
fix imports
cekk Jan 30, 2024
ada5678
Merge branch 'add_getobjsize_info_in_serializer' into v2v3_test
cekk Jan 30, 2024
61f9a75
Merge branch 'main' into optional_navigation
cekk Jan 31, 2024
a2bb209
Merge branch 'optional_navigation' into v2v3_test
cekk Jan 31, 2024
a3d0279
enhance Bandi serializer for enhancedlinks features
cekk Jan 31, 2024
bacbc65
Merge branch 'add_getobjsize_info_in_serializer' into v2v3_test
cekk Jan 31, 2024
a897111
Merge branch 'main' into v2v3_test
cekk Feb 7, 2024
4b6eb12
fix check
cekk Feb 7, 2024
1fe7f29
Fix in @scadenziario endpoint: return future events if afterToday cri…
cekk Feb 12, 2024
7d452df
Merge branch 'fix_scadenziario_with_afterToday_crit' into v2v3_test
cekk Feb 12, 2024
5a467c4
Merge branch 'main' into v2v3_test
cekk Feb 28, 2024
3944b7f
fix upgrade-steps
cekk Feb 28, 2024
aeabe20
removed unused logger
cekk Mar 4, 2024
d4821fd
fix tests
cekk Mar 4, 2024
92ece11
standardize subfolders creation in events
cekk Mar 4, 2024
e8087f0
update changelog
cekk Mar 4, 2024
2e08c7f
zpretty
cekk Mar 4, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,14 @@ Changelog
6.1.15 (unreleased)
-------------------

- Nothing changed yet.

- Remove unused behavior (design.plone.contenttypes.behavior.geolocation_uo).
[cekk]
- Standardize subfolders creations in events.
[cekk]
- Do not return a fieldset if it has all fields hidden (maybe after a schema tweak).
[cekk]
- Improve types test for their schema, required fields, fieldsets.
[cekk]

6.1.14 (2024-02-20)
-------------------
Expand All @@ -19,7 +25,6 @@ Changelog
[eikichi18]



6.1.13 (2024-02-08)
-------------------

Expand Down
1 change: 1 addition & 0 deletions base.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -143,3 +143,4 @@ design.plone.contenttypes =
#redturtle.volto = git https://github.com/RedTurtle/redturtle.volto.git [email protected]:RedTurtle/redturtle.volto.git
#redturtle.bandi = git https://github.com/RedTurtle/redturtle.bandi.git [email protected]:RedTurtle/redturtle.bandi.git
#plone.restapi = git https://github.com/plone/plone.restapi.git
collective.volto.enhancedlinks = git https://github.com/RegioneER/collective.volto.enhancedlinks.git [email protected]:RegioneER/collective.volto.enhancedlinks.git branch=main
1 change: 1 addition & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@
"z3c.unconfigure",
"eea.api.taxonomy",
"openpyxl",
"collective.volto.enhancedlinks",
],
extras_require={
"test": [
Expand Down
1 change: 1 addition & 0 deletions src/design/plone/contenttypes/adapters/configure.zcml
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,5 @@
factory=".searchabletext_indexers.TextBlockSearchableText"
name="text"
/>

</configure>
8 changes: 0 additions & 8 deletions src/design/plone/contenttypes/behaviors/configure.zcml
Original file line number Diff line number Diff line change
Expand Up @@ -261,14 +261,6 @@
provides=".contatti.IContattiEvent"
marker=".contatti.IContattiEvent"
/>
<plone:behavior
name="design.plone.contenttypes.behavior.geolocation_uo"
title="Geolocatable"
description="Behavior geolocatable per UO."
factory=".geolocation.GeolocatableUnitaOrganizzativa"
provides=".geolocation.IGeolocatableUnitaOrganizzativa"
marker=".geolocation.IGeolocatableUnitaOrganizzativa"
/>
<plone:behavior
name="design.plone.contenttypes.behavior.geolocation_venue"
title="Geolocatable"
Expand Down
19 changes: 0 additions & 19 deletions src/design/plone/contenttypes/events/bando.py

This file was deleted.

169 changes: 169 additions & 0 deletions src/design/plone/contenttypes/events/common.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,142 @@
# -*- 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": [
{"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": [
{
"id": "multimedia",
"title": "Multimedia",
"type": "Document",
"allowed_types": ("Image",),
},
],
"Event": [
{
"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": [
{"id": "compensi-file", "title": "Compensi", "allowed": ("File",)},
{
"id": "importi-di-viaggio-e-o-servizi",
"title": "Importi di viaggio e/o servizi",
"allowed_types": ("File",),
},
],
"Venue": [
{
"id": "multimedia",
"title": "Multimedia",
"type": "Folder",
"allowed_types": (
"Image",
"Link",
),
"publish": True,
}
],
"News Item": [
{
"id": "multimedia",
"title": "Multimedia",
"allowed_types": (
"Image",
"Link",
),
},
{
"id": "documenti-allegati",
"title": "Documenti allegati",
"allowed_types": (
"File",
"Image",
),
},
],
"Persona": [
{
"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",)},
],
"Pratica": [
{
"id": "allegati",
"title": "Allegati",
"type": "Folder",
"allowed_types": ("File",),
}
],
"Servizio": [
{"id": "modulistica", "title": "Modulistica", "contains": ("File", "Link")},
{"id": "allegati", "title": "Allegati", "contains": ("File", "Link")},
],
"UnitaOrganizzativa": [
{"id": "allegati", "title": "Allegati", "contains": ("File",)},
],
}


def onModify(context, event):
Expand All @@ -8,3 +146,34 @@ def onModify(context, event):
) 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:
if mapping["id"] not in context.keys():
child = api.content.create(
container=context,
type=mapping.get("type", "Document"),
title=mapping["title"],
id=mapping["id"],
)
create_default_blocks(context=child)

# select constraints
if mapping.get("allowed_types", ()):
constraintsChild = ISelectableConstrainTypes(child)
constraintsChild.setConstrainTypesMode(1)
constraintsChild.setLocallyAllowedTypes(mapping["allowed_types"])

if mapping.get("publish", False):
with api.env.adopt_roles(["Reviewer"]):
api.content.transition(obj=child, transition="publish")
56 changes: 5 additions & 51 deletions src/design/plone/contenttypes/events/configure.zcml
Original file line number Diff line number Diff line change
Expand Up @@ -5,46 +5,6 @@
i18n_domain="design.plone.contenttypes"
>

<subscriber
for="design.plone.contenttypes.interfaces.pratica.IPratica
zope.lifecycleevent.interfaces.IObjectAddedEvent"
handler=".pratica.praticaCreateHandler"
/>
<subscriber
for="collective.venue.interfaces.IVenue
zope.lifecycleevent.interfaces.IObjectAddedEvent"
handler=".luogo.luogoCreateHandler"
/>
<subscriber
for="design.plone.contenttypes.interfaces.unita_organizzativa.IUnitaOrganizzativa
zope.lifecycleevent.interfaces.IObjectAddedEvent"
handler=".unita_organizzativa.unitaOrganizzativaCreateHandler"
/>
<subscriber
for="design.plone.contenttypes.interfaces.persona.IPersona
zope.lifecycleevent.interfaces.IObjectAddedEvent"
handler=".persona.personaCreateHandler"
/>
<subscriber
for="plone.event.interfaces.IEvent
zope.lifecycleevent.interfaces.IObjectAddedEvent"
handler=".evento.eventoCreateHandler"
/>
<subscriber
for="design.plone.contenttypes.interfaces.documento.IDocumento
zope.lifecycleevent.interfaces.IObjectAddedEvent"
handler=".documento.documentoCreateHandler"
/>
<subscriber
for="design.plone.contenttypes.interfaces.servizio.IServizio
zope.lifecycleevent.interfaces.IObjectAddedEvent"
handler=".servizio.servizioCreateHandler"
/>
<subscriber
for="plone.app.contenttypes.interfaces.INewsItem
zope.lifecycleevent.interfaces.IObjectAddedEvent"
handler=".notizie_e_comunicati_stampa.notiziaCreateHandler"
/>
<subscriber
for="design.plone.contenttypes.interfaces.pagina_argomento.IPaginaArgomento
zope.lifecycleevent.interfaces.IObjectModifiedEvent"
Expand All @@ -55,16 +15,6 @@
zope.lifecycleevent.interfaces.IObjectAddedEvent"
handler=".document.documentCreateHandler"
/>
<subscriber
for="redturtle.bandi.interfaces.bando.IBando
zope.lifecycleevent.interfaces.IObjectAddedEvent"
handler=".bando.bandoCreateHandler"
/>
<subscriber
for="design.plone.contenttypes.interfaces.incarico.IIncarico
zope.lifecycleevent.interfaces.IObjectAddedEvent"
handler=".incarico.incaricoCreateHandler"
/>
<subscriber
for="design.plone.contenttypes.interfaces.incarico.IIncarico
zope.lifecycleevent.interfaces.IObjectModifiedEvent"
Expand All @@ -76,5 +26,9 @@
zope.lifecycleevent.interfaces.IObjectModifiedEvent"
handler=".common.onModify"
/>

<subscriber
for="plone.dexterity.interfaces.IDexterityContent
zope.lifecycleevent.interfaces.IObjectAddedEvent"
handler=".common.createSubfolders"
/>
</configure>
36 changes: 0 additions & 36 deletions src/design/plone/contenttypes/events/documento.py

This file was deleted.

Loading
Loading