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

Us64153 fine effettiva #304

Merged
merged 4 commits into from
Mar 20, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
3 changes: 3 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,12 @@ Changelog
[lucabel]
- Add upgrade-step to add missing metadata for image captions.
[cekk]
- Add "data fine effettiva" for events, to order listing correctly
[lucabel]
- Fix typo in Venue serializer that didn't return the right history version.
[cekk]


6.3.4 (2025-03-07)
------------------

Expand Down
9 changes: 9 additions & 0 deletions src/design/plone/contenttypes/configure.zcml
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,15 @@
provides="Products.GenericSetup.interfaces.EXTENSION"
directory="profiles/remove_eea_api_taxonomy"
/>

<genericsetup:registerProfile
name="to_7313"
title="Design Plone: Content-types to 7313"
description="Fix control panel of design.plone.contenttypes add-on."
provides="Products.GenericSetup.interfaces.EXTENSION"
directory="profiles/to_7313"
/>

<utility
factory=".setuphandlers.HiddenProfiles"
name="design.plone.contenttypes-hiddenprofiles"
Expand Down
4 changes: 4 additions & 0 deletions src/design/plone/contenttypes/indexers/configure.zcml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@
factory=".events.effectivestart"
name="effectivestart"
/>
<adapter
factory=".events.effectiveend"
name="effectiveend"
/>
<adapter
factory=".pagina_argomento.SearchableTextExtender"
name="IPaginaArgomento"
Expand Down
13 changes: 13 additions & 0 deletions src/design/plone/contenttypes/indexers/events.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
from plone.app.contenttypes.interfaces import IEvent
from plone.indexer.decorator import indexer
from plone.event.interfaces import IEventAccessor
from plone.event.interfaces import IRecurrenceSupport


@indexer(IEvent)
Expand All @@ -26,3 +27,15 @@ def effectivestart(obj):
if not start:
raise AttributeError
return start


@indexer(IEvent)
def effectiveend(obj):
occurrences = IRecurrenceSupport(obj).occurrences()
end = obj.end
for occurrence in list(occurrences):
if occurrence.end > end:
end = occurrence.end
if obj.title:
print(f"{obj.title} - {end}")
return end
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<metadata>
<version>7312</version>
<version>7313</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 @@ -588,5 +588,24 @@
</value>
<value i18n:translate="" i18n:domain="plone" key="group">Dates</value>
</records>

<records interface="plone.app.querystring.interfaces.IQueryField"
prefix="plone.app.querystring.field.effectiveend">
<value key="title" i18n:translate="effectivestart">Data effettiva di fine evento</value>
<value key="description">Criterio per ricerche che si basano sulla data effettiva di fine</value>
<value key="enabled">True</value>
<value key="sortable">True</value>
<value key="operations">
<element>plone.app.querystring.operation.date.lessThan</element>
<element>plone.app.querystring.operation.date.largerThan</element>
<element>plone.app.querystring.operation.date.between</element>
<element>plone.app.querystring.operation.date.lessThanRelativeDate</element>
<element>plone.app.querystring.operation.date.largerThanRelativeDate</element>
<element>plone.app.querystring.operation.date.today</element>
<element>plone.app.querystring.operation.date.beforeToday</element>
<element>plone.app.querystring.operation.date.afterToday</element>
<element>plone.app.querystring.operation.date.beforeRelativeDate</element>
<element>plone.app.querystring.operation.date.afterRelativeDate</element>
</value>
<value i18n:translate="" i18n:domain="plone" key="group">Dates</value>
</records>
</registry>
25 changes: 25 additions & 0 deletions src/design/plone/contenttypes/profiles/to_7313/registry.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?xml version="1.0" encoding="utf-8"?>
<registry xmlns:i18n="http://xml.zope.org/namespaces/i18n"
i18n:domain="plone"
>
<records interface="plone.app.querystring.interfaces.IQueryField"
prefix="plone.app.querystring.field.effectiveend" >
<value key="title" i18n:translate="effectivestart">Data effettiva di fine evento</value>
<value key="description">Criterio per ricerche che si basano sulla data effettiva di fine</value>
<value key="enabled">True</value>
<value key="sortable">True</value>
<value key="operations">
<element>plone.app.querystring.operation.date.lessThan</element>
<element>plone.app.querystring.operation.date.largerThan</element>
<element>plone.app.querystring.operation.date.between</element>
<element>plone.app.querystring.operation.date.lessThanRelativeDate</element>
<element>plone.app.querystring.operation.date.largerThanRelativeDate</element>
<element>plone.app.querystring.operation.date.today</element>
<element>plone.app.querystring.operation.date.beforeToday</element>
<element>plone.app.querystring.operation.date.afterToday</element>
<element>plone.app.querystring.operation.date.beforeRelativeDate</element>
<element>plone.app.querystring.operation.date.afterRelativeDate</element>
</value>
<value i18n:translate="" i18n:domain="plone" key="group">Dates</value>
</records>
</registry>
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 @@ -941,4 +941,11 @@
destination="7312"
handler=".to_730x.to_7312"
/>
<genericsetup:upgradeStep
title="Add caption metadata"
profile="design.plone.contenttypes:default"
source="7312"
destination="7313"
handler=".to_730x.to_7313"
/>
</configure>
28 changes: 28 additions & 0 deletions src/design/plone/contenttypes/upgrades/to_730x.py
Original file line number Diff line number Diff line change
Expand Up @@ -197,3 +197,31 @@ def to_7312(context):
for column in ["image_caption", "preview_caption"]:
if column not in pc.schema():
pc.addColumn(column)


def to_7313(context):
logger.info("Update registry")
context.runImportStepFromProfile(
"profile-design.plone.contenttypes:to_7313", "plone.app.registry", False
)

logger.info("Add new effectiveend (DateRecurringIndex) index")

class extra:
recurdef = "recurrence"
until = ""

name = "effectiveend"
catalog = api.portal.get_tool(name="portal_catalog")

if "effectiveend" not in catalog.indexes():
catalog.addIndex(name, "DateRecurringIndex", extra=extra())
logger.info("Catalog DateRecurringIndex {} created.".format(name))

logger.info("Reindex Events")
brains = catalog(portal_type="Event")
tot = len(brains)
for i, brain in enumerate(brains):
if i % 15 == 0:
logger.info("Progress: {}/{}".format(i, tot))
brain.getObject().reindexObject(idxs=["effectiveend"])