Skip to content

Commit

Permalink
Merge branch 'master' into fix_indexes
Browse files Browse the repository at this point in the history
  • Loading branch information
cekk committed Apr 18, 2024
2 parents 3e4d682 + fa82b46 commit 8e150ea
Show file tree
Hide file tree
Showing 8 changed files with 59 additions and 5 deletions.
16 changes: 15 additions & 1 deletion docs/HISTORY.txt
Original file line number Diff line number Diff line change
@@ -1,13 +1,27 @@
Changelog
=========

1.4.4 (unreleased)
1.4.6 (unreleased)
------------------

- Do not use key/value pairs in tipologia_bando and destinatari.
[cekk]


1.4.5 (2024-04-15)
------------------

- Added "tipologia_bando_label" metadata.
[daniele]


1.4.4 (2024-02-20)
------------------

- Changed translation for states "Open" and "Closed".
[daniele]


1.4.3 (2023-06-27)
------------------

Expand Down
1 change: 1 addition & 0 deletions redturtle/bandi/configure.zcml
Original file line number Diff line number Diff line change
Expand Up @@ -80,5 +80,6 @@
<adapter name="scadenza_bando" factory=".indexer.scadenza_bando" />
<adapter name="ente_bando" factory=".indexer.ente_bando" />
<adapter name="tipologia_bando" factory=".indexer.tipologia_bando" />
<adapter name="tipologia_bando_label" factory=".indexer.tipologia_bando_label" />
<adapter name="apertura_bando" factory=".indexer.apertura_bando" />
</configure>
13 changes: 13 additions & 0 deletions redturtle/bandi/indexer.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
from DateTime import DateTime
from plone.indexer.decorator import indexer
from redturtle.bandi.interfaces.bando import IBando
from redturtle.bandi.vocabularies import TipologiaBandoVocabulary

# importo il datetime di python
from datetime import datetime
Expand Down Expand Up @@ -63,3 +64,15 @@ def ente_bando(object, **kw):
@indexer(IBando)
def tipologia_bando(object, **kw):
return getattr(object, "tipologia_bando", None)


@indexer(IBando)
def tipologia_bando_label(object, **kw):
if not object.tipologia_bando:
return None
vocab = TipologiaBandoVocabulary().__call__(object)
try:
vocab.getTermByToken(object.tipologia_bando)
except LookupError:
return None
return vocab.getTermByToken(object.tipologia_bando).title
4 changes: 2 additions & 2 deletions redturtle/bandi/locales/it/LC_MESSAGES/redturtle.bandi.po
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ msgstr ""
#: redturtle/bandi/browser/bando.py:226
#: redturtle/bandi/portlets/collection.py:261
msgid "Closed"
msgstr "Chiuso"
msgstr "Scaduto"

#: redturtle/bandi/browser/configure.zcml:46
msgid "Default"
Expand Down Expand Up @@ -74,7 +74,7 @@ msgstr ""
#: redturtle/bandi/browser/bando.py:216
#: redturtle/bandi/portlets/collection.py:253
msgid "Open"
msgstr "Aperto"
msgstr "Attivo"

#: redturtle/bandi/portlets/collection.py:22
msgid "Other text"
Expand Down
1 change: 1 addition & 0 deletions redturtle/bandi/profiles/default/catalog.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,5 @@
<column value="destinatari_bando"/>
<column value="scadenza_bando"/>
<column value="tipologia_bando"/>
<column value="tipologia_bando_label"/>
</object>
16 changes: 16 additions & 0 deletions redturtle/bandi/upgrades.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,22 @@ def migrate_to_2101(context):
bando.reindexObject(idxs=["scadenza_bando"])


def migrate_to_2102(context):
update_catalog(context)

bandi = api.content.find(portal_type="Bando")
tot_results = len(bandi)
logger.info("### Fixing {tot} Bandi ###".format(tot=tot_results))
for counter, brain in enumerate(bandi):
logger.info(
"[{counter}/{tot}] - {bando}".format(
counter=counter + 1, tot=tot_results, bando=brain.getPath()
)
)
bando = brain.getObject()
bando.reindexObject(idxs=["tipologia_bando_label"])


def migrate_to_2200(context):
from Acquisition import aq_base
from plone.dexterity.utils import iterSchemata
Expand Down
11 changes: 10 additions & 1 deletion redturtle/bandi/upgrades.zcml
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,19 @@
profile="redturtle.bandi:default" />

<gs:upgradeStep
title="Do not use key/token pairs in vocabs"
title="Add new metadata for tipologia_bando_label"
description=""
source="2101"
destination="2102"
handler=".upgrades.migrate_to_2102"
profile="redturtle.bandi:default" />

<gs:upgradeStep
title="Do not use key/token pairs in vocabs"
description=""
source="2102"
destination="2200"
handler=".upgrades.migrate_to_2200"
profile="redturtle.bandi:default" />

</configure>
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import os
from setuptools import setup, find_packages

version = "1.4.4.dev0"
version = "1.4.6.dev0"

setup(
name="redturtle.bandi",
Expand Down

0 comments on commit 8e150ea

Please sign in to comment.