Skip to content

Commit

Permalink
update ricorrenze reggio
Browse files Browse the repository at this point in the history
  • Loading branch information
luca-bellenghi committed Oct 22, 2024
1 parent f1c4f86 commit 7620795
Show file tree
Hide file tree
Showing 6 changed files with 75 additions and 2 deletions.
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 @@ -4,6 +4,10 @@
factory=".events.event_location"
name="event_location"
/>
<adapter
factory=".events.effectivestart"
name="effectivestart"
/>
<adapter
factory=".pagina_argomento.SearchableTextExtender"
name="IPaginaArgomento"
Expand Down
9 changes: 9 additions & 0 deletions src/design/plone/contenttypes/indexers/events.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# -*- coding: utf-8 -*-
from plone.app.contenttypes.interfaces import IEvent
from plone.indexer.decorator import indexer
from plone.event.interfaces import IEventAccessor


@indexer(IEvent)
Expand All @@ -17,3 +18,11 @@ def rassegna(context, **kw):
""" """
children = context.values()
return "Event" in [child.portal_type for child in children]


@indexer(IEvent)
def effectivestart(obj):
start = IEventAccessor(obj).start
if not start:
raise AttributeError
return start
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<metadata>
<version>7306</version>
<version>7308</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 @@ -568,4 +568,25 @@
remove="True"
>
</records>
<records interface="plone.app.querystring.interfaces.IQueryField"
prefix="plone.app.querystring.field.effectivestart">
<value key="title" i18n:translate="effectivestart">Data effettiva di inizio evento</value>
<value key="description">Criterio per ricerche che si basano sulla data effettiva di inizio</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>
15 changes: 14 additions & 1 deletion src/design/plone/contenttypes/upgrades/configure.zcml
Original file line number Diff line number Diff line change
Expand Up @@ -898,5 +898,18 @@
destination="7306"
handler=".to_730x.to_7306"
/>

<genericsetup:upgradeStep
title="Reload registry"
profile="design.plone.contenttypes:default"
source="7306"
destination="7307"
handler=".to_730x.to_7307"
/>
<genericsetup:upgradeStep
title="Reload registry"
profile="design.plone.contenttypes:default"
source="7307"
destination="7308"
handler=".to_730x.to_7308"
/>
</configure>
26 changes: 26 additions & 0 deletions src/design/plone/contenttypes/upgrades/to_730x.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,3 +132,29 @@ def to_7306(context):
if behavior not in behaviors:
behaviors.append(behavior)
portal_type.behaviors = tuple(behaviors)


def to_7307(context):
logger.info("Update registry")
update_registry(context)
logger.info("Add new effectivestart (DateRecurringIndex) index")

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

name = "effectivestart"
catalog = api.portal.get_tool(name="portal_catalog")
catalog.addIndex(name, "DateRecurringIndex", extra=extra())
logger.info("Catalog DateRecurringIndex {} created.".format(name))


def to_7308(context):
logger.info("Reindex Events")
pc = api.portal.get_tool(name="portal_catalog")
brains = pc(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=["effectivestart"])

0 comments on commit 7620795

Please sign in to comment.