Skip to content

Commit ffedc45

Browse files
Us64153 fine effettiva (#304)
* merge with main * add index and profile to add index * black
1 parent dfcf674 commit ffedc45

File tree

9 files changed

+110
-2
lines changed

9 files changed

+110
-2
lines changed

CHANGES.rst

+3
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,12 @@ Changelog
1111
[lucabel]
1212
- Add upgrade-step to add missing metadata for image captions.
1313
[cekk]
14+
- Add "data fine effettiva" for events, to order listing correctly
15+
[lucabel]
1416
- Fix typo in Venue serializer that didn't return the right history version.
1517
[cekk]
1618

19+
1720
6.3.4 (2025-03-07)
1821
------------------
1922

src/design/plone/contenttypes/configure.zcml

+9
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,15 @@
7272
provides="Products.GenericSetup.interfaces.EXTENSION"
7373
directory="profiles/remove_eea_api_taxonomy"
7474
/>
75+
76+
<genericsetup:registerProfile
77+
name="to_7313"
78+
title="Design Plone: Content-types to 7313"
79+
description="Fix control panel of design.plone.contenttypes add-on."
80+
provides="Products.GenericSetup.interfaces.EXTENSION"
81+
directory="profiles/to_7313"
82+
/>
83+
7584
<utility
7685
factory=".setuphandlers.HiddenProfiles"
7786
name="design.plone.contenttypes-hiddenprofiles"

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

+4
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@
88
factory=".events.effectivestart"
99
name="effectivestart"
1010
/>
11+
<adapter
12+
factory=".events.effectiveend"
13+
name="effectiveend"
14+
/>
1115
<adapter
1216
factory=".pagina_argomento.SearchableTextExtender"
1317
name="IPaginaArgomento"

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

+13
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
from plone.app.contenttypes.interfaces import IEvent
33
from plone.indexer.decorator import indexer
44
from plone.event.interfaces import IEventAccessor
5+
from plone.event.interfaces import IRecurrenceSupport
56

67

78
@indexer(IEvent)
@@ -26,3 +27,15 @@ def effectivestart(obj):
2627
if not start:
2728
raise AttributeError
2829
return start
30+
31+
32+
@indexer(IEvent)
33+
def effectiveend(obj):
34+
occurrences = IRecurrenceSupport(obj).occurrences()
35+
end = obj.end
36+
for occurrence in list(occurrences):
37+
if occurrence.end > end:
38+
end = occurrence.end
39+
if obj.title:
40+
print(f"{obj.title} - {end}")
41+
return end

src/design/plone/contenttypes/profiles/default/metadata.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<metadata>
3-
<version>7312</version>
3+
<version>7313</version>
44
<dependencies>
55
<dependency>profile-redturtle.bandi:default</dependency>
66
<dependency>profile-collective.venue:default</dependency>

src/design/plone/contenttypes/profiles/default/registry/criteria.xml

+20-1
Original file line numberDiff line numberDiff line change
@@ -588,5 +588,24 @@
588588
</value>
589589
<value i18n:translate="" i18n:domain="plone" key="group">Dates</value>
590590
</records>
591-
591+
<records interface="plone.app.querystring.interfaces.IQueryField"
592+
prefix="plone.app.querystring.field.effectiveend">
593+
<value key="title" i18n:translate="effectivestart">Data effettiva di fine evento</value>
594+
<value key="description">Criterio per ricerche che si basano sulla data effettiva di fine</value>
595+
<value key="enabled">True</value>
596+
<value key="sortable">True</value>
597+
<value key="operations">
598+
<element>plone.app.querystring.operation.date.lessThan</element>
599+
<element>plone.app.querystring.operation.date.largerThan</element>
600+
<element>plone.app.querystring.operation.date.between</element>
601+
<element>plone.app.querystring.operation.date.lessThanRelativeDate</element>
602+
<element>plone.app.querystring.operation.date.largerThanRelativeDate</element>
603+
<element>plone.app.querystring.operation.date.today</element>
604+
<element>plone.app.querystring.operation.date.beforeToday</element>
605+
<element>plone.app.querystring.operation.date.afterToday</element>
606+
<element>plone.app.querystring.operation.date.beforeRelativeDate</element>
607+
<element>plone.app.querystring.operation.date.afterRelativeDate</element>
608+
</value>
609+
<value i18n:translate="" i18n:domain="plone" key="group">Dates</value>
610+
</records>
592611
</registry>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<registry xmlns:i18n="http://xml.zope.org/namespaces/i18n"
3+
i18n:domain="plone"
4+
>
5+
<records interface="plone.app.querystring.interfaces.IQueryField"
6+
prefix="plone.app.querystring.field.effectiveend" >
7+
<value key="title" i18n:translate="effectivestart">Data effettiva di fine evento</value>
8+
<value key="description">Criterio per ricerche che si basano sulla data effettiva di fine</value>
9+
<value key="enabled">True</value>
10+
<value key="sortable">True</value>
11+
<value key="operations">
12+
<element>plone.app.querystring.operation.date.lessThan</element>
13+
<element>plone.app.querystring.operation.date.largerThan</element>
14+
<element>plone.app.querystring.operation.date.between</element>
15+
<element>plone.app.querystring.operation.date.lessThanRelativeDate</element>
16+
<element>plone.app.querystring.operation.date.largerThanRelativeDate</element>
17+
<element>plone.app.querystring.operation.date.today</element>
18+
<element>plone.app.querystring.operation.date.beforeToday</element>
19+
<element>plone.app.querystring.operation.date.afterToday</element>
20+
<element>plone.app.querystring.operation.date.beforeRelativeDate</element>
21+
<element>plone.app.querystring.operation.date.afterRelativeDate</element>
22+
</value>
23+
<value i18n:translate="" i18n:domain="plone" key="group">Dates</value>
24+
</records>
25+
</registry>

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

+7
Original file line numberDiff line numberDiff line change
@@ -941,4 +941,11 @@
941941
destination="7312"
942942
handler=".to_730x.to_7312"
943943
/>
944+
<genericsetup:upgradeStep
945+
title="Add caption metadata"
946+
profile="design.plone.contenttypes:default"
947+
source="7312"
948+
destination="7313"
949+
handler=".to_730x.to_7313"
950+
/>
944951
</configure>

src/design/plone/contenttypes/upgrades/to_730x.py

+28
Original file line numberDiff line numberDiff line change
@@ -197,3 +197,31 @@ def to_7312(context):
197197
for column in ["image_caption", "preview_caption"]:
198198
if column not in pc.schema():
199199
pc.addColumn(column)
200+
201+
202+
def to_7313(context):
203+
logger.info("Update registry")
204+
context.runImportStepFromProfile(
205+
"profile-design.plone.contenttypes:to_7313", "plone.app.registry", False
206+
)
207+
208+
logger.info("Add new effectiveend (DateRecurringIndex) index")
209+
210+
class extra:
211+
recurdef = "recurrence"
212+
until = ""
213+
214+
name = "effectiveend"
215+
catalog = api.portal.get_tool(name="portal_catalog")
216+
217+
if "effectiveend" not in catalog.indexes():
218+
catalog.addIndex(name, "DateRecurringIndex", extra=extra())
219+
logger.info("Catalog DateRecurringIndex {} created.".format(name))
220+
221+
logger.info("Reindex Events")
222+
brains = catalog(portal_type="Event")
223+
tot = len(brains)
224+
for i, brain in enumerate(brains):
225+
if i % 15 == 0:
226+
logger.info("Progress: {}/{}".format(i, tot))
227+
brain.getObject().reindexObject(idxs=["effectiveend"])

0 commit comments

Comments
 (0)