Skip to content

Commit

Permalink
Added 'tipologia_bando_label' metadata.
Browse files Browse the repository at this point in the history
  • Loading branch information
daniele-andreotti committed Mar 27, 2024
1 parent a7d62fe commit c343f83
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 1 deletion.
3 changes: 2 additions & 1 deletion docs/HISTORY.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ Changelog
1.4.5 (unreleased)
------------------

- Nothing changed yet.
- Added "tipologia_bando_label" metadata.
[daniele]


1.4.4 (2024-02-20)
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>
9 changes: 9 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,11 @@ 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)
return vocab.getTermByToken(object.tipologia_bando).title
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>

0 comments on commit c343f83

Please sign in to comment.