Skip to content

Commit

Permalink
updated field finanziamenti
Browse files Browse the repository at this point in the history
  • Loading branch information
Plone su Server Crul committed Nov 7, 2024
1 parent c829c2a commit add32f6
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 16 deletions.
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
4.2.1 (unreleased)
------------------

- Nothing changed yet.
- Refactoring for field finanziamenti #28788
[daniele]


4.2.0 (2022-01-26)
Expand Down
4 changes: 2 additions & 2 deletions rer/bandi/browser/bando-right.pt
Original file line number Diff line number Diff line change
Expand Up @@ -137,8 +137,8 @@
</div>
<div class="finanziatori-bando" tal:define="finanziato context/finanziato"
tal:condition="finanziato">
<strong><span i18n:translate="finanziatori_label">Financed by EU programmes</span>:</strong>
<span tal:content="python:' | '.join(finanziato)"></span>
<strong><span i18n:translate="finanziatori_label">Financed by EU programmes</span></strong>
<!--span tal:content="python:' | '.join(finanziato)"></span-->
</div>
</div>
<div class="visualClear"></div>
Expand Down
4 changes: 2 additions & 2 deletions rer/bandi/browser/bando.pt
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,8 @@
</div>
<div class="finanziatori-bando" tal:define="finanziato context/finanziato"
tal:condition="finanziato">
<strong><span i18n:translate="finanziatori_label">Financed by EU programmes</span>:</strong>
<span tal:content="python:' | '.join(finanziato)"></span>
<strong><span i18n:translate="finanziatori_label">Financed by EU programmes</span></strong>
<!--span tal:content="finanziato"></span-->
</div>
</div>
<div class="visualClear"></div>
Expand Down
2 changes: 1 addition & 1 deletion rer/bandi/profiles/default/catalog.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<index name="tipologia_bando" meta_type="FieldIndex">
<indexed_attr value="tipologia_bando"/>
</index>
<index name="finanziato" meta_type="KeywordIndex">
<index name="finanziato" meta_type="BooleanIndex">
<indexed_attr value="finanziato"/>
</index>
<index name="materie" meta_type="KeywordIndex">
Expand Down
2 changes: 1 addition & 1 deletion rer/bandi/profiles/migrate_to_3200/catalog.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0"?>
<object name="portal_catalog" meta_type="Plone Catalog Tool">

<index name="fiinanziatori" remove="True" />
<index name="finanziatori" remove="True" />
</object>
24 changes: 16 additions & 8 deletions rer/bandi/upgrades.py
Original file line number Diff line number Diff line change
Expand Up @@ -242,9 +242,6 @@ def migrate_to_3200(context):
)
)
bando = brain.getObject()
import pdb

pdb.set_trace()
if getattr(bando, "finanziatori", []):
setattr(bando, "finanziato", True)
keywords = [k for k in getattr(bando, "finanziatori", []) if k]
Expand All @@ -269,16 +266,27 @@ def migrate_to_3200(context):
logger.info("### Fixing {tot} Collections ###".format(tot=tot_results))
for counter, brain in enumerate(collections):
collection = brain.getObject()

crit_list = collection.query
filtered_crit = [x for x in crit_list if x['i'] == "finanziatori"]
if not filtered_crit:
continue

query = []
for criteria in getattr(collection, "query", []):
if criteria["i"] == "finanziatori":
criteria["o"] = 'plone.app.querystring.operation.boolean.isTrue'
criteria["v"] = ""
criteria["i"] = criteria_mapping.get(criteria["i"], criteria["i"])
query.append(criteria)

if criteria not in query:
query.append(criteria)
collection.query = query

# fix sort_on
sort_on = getattr(collection, "sort_on", "")
if sort_on in criteria_mapping:
collection.sort_on = criteria_mapping[sort_on]
#sort_on = getattr(collection, "sort_on", "")
#if sort_on in criteria_mapping:
# collection.sort_on = criteria_mapping[sort_on]

logger.info(
"[{counter}/{tot}] - {collection}".format(
Expand All @@ -287,4 +295,4 @@ def migrate_to_3200(context):
collection=brain.getPath(),
)
)
logger.info("Upgrade to 3100 complete")
logger.info("Upgrade to 3200 complete")
2 changes: 1 addition & 1 deletion rer/bandi/vocabularies/vocabularies.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ class BandiBaseVocabularyFactory(object):
@property
def terms(self):
return [
SimpleTerm(value=x, token=x.encode("utf-8"), title=x)
SimpleTerm(value=x, token=x.decode("utf-8"), title=x)
for x in self.vocab_name
]

Expand Down

0 comments on commit add32f6

Please sign in to comment.