Skip to content

Commit

Permalink
Merge pull request #63 from RegioneER/us_59839
Browse files Browse the repository at this point in the history
Refactored finanziamenti field
  • Loading branch information
cekk authored Dec 5, 2024
2 parents d0bd3f8 + fe21f25 commit b82fd60
Show file tree
Hide file tree
Showing 26 changed files with 604 additions and 501 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
12 changes: 7 additions & 5 deletions rer/bandi/browser/bando-right.pt
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,13 @@
</div>
</td>
</tr>
<tr tal:define="finanziato context/finanziato" tal:condition="finanziato">
<td colspan="2">
<strong>
<span i18n:translate="finanziatori_label">Financed by EU programmes</span>
</strong>
</td>
</tr>
</table>

<div class="rer-contextual-portlets">
Expand Down Expand Up @@ -135,11 +142,6 @@
<strong><span i18n:translate="materie_label">Topic</span>:</strong>
<span tal:content="python:' | '.join(materie)"></span>
</div>
<div class="finanziatori-bando" tal:define="finanziatori context/finanziatori"
tal:condition="finanziatori">
<strong><span i18n:translate="finanziatori_label">Financed by EU programmes</span>:</strong>
<span tal:content="python:' | '.join(finanziatori)"></span>
</div>
</div>
<div class="visualClear"></div>
<div tal:replace="structure provider:plone.belowcontentbody" />
Expand Down
13 changes: 7 additions & 6 deletions rer/bandi/browser/bando.pt
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,13 @@
${context/tipologia_bando}
</td>
</tr>

<tr tal:define="finanziato context/finanziato" tal:condition="finanziato">
<td colspan="2">
<strong>
<span i18n:translate="finanziatori_label">Financed by EU programmes</span>
</strong>
</td>
</tr>
<tr tal:condition="context/destinatari|nothing">
<th i18n:translate="destinatari_label">Who can apply</th>
<td>
Expand Down Expand Up @@ -113,11 +119,6 @@
<strong><span i18n:translate="materie_label">Topic</span>:</strong>
<span tal:content="python:' | '.join(materie)"></span>
</div>
<div class="finanziatori-bando" tal:define="finanziatori context/finanziatori"
tal:condition="finanziatori">
<strong><span i18n:translate="finanziatori_label">Financed by EU programmes</span>:</strong>
<span tal:content="python:' | '.join(finanziatori)"></span>
</div>
</div>
<div class="visualClear"></div>
<section id="foldeeps">
Expand Down
19 changes: 6 additions & 13 deletions rer/bandi/browser/static/dist/prod/main.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion rer/bandi/browser/static/dist/prod/main.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ const SelectField = ({ parameter, value = [], updateQueryParameters }) => {
const placeholderLabel = multivalued
? 'select_placeholder_multi'
: 'select_placeholder';

return (
<React.Fragment>
<label htmlFor={parameter.id}>{parameter.label}</label>
Expand All @@ -20,18 +21,22 @@ const SelectField = ({ parameter, value = [], updateQueryParameters }) => {
<Select
isMulti={multivalued}
inputId={parameter.id}
isClearable={true}
tabSelectsValue={false}
value={value.map(element => {
return {
value: element,
label:
element !== ''
? getTranslationFor(
`bando_state_${element}_select_label`,
element,
)
: getTranslationFor('bando_state_all_select_label', element),
};
if (parameter.id === 'stato_bandi') {
return {
value: element,
label:
element !== ''
? getTranslationFor(
`bando_state_${element}_select_label`,
element,
)
: getTranslationFor('bando_state_all_select_label', element),
};
}
return parameter.options.filter(x => x.value === element)[0];
})}
name={parameter.id}
options={parameter.options}
Expand Down
10 changes: 9 additions & 1 deletion rer/bandi/configure.zcml
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,14 @@
provides="Products.GenericSetup.interfaces.EXTENSION"
/>

<genericsetup:registerProfile
name="migrate_to_3200"
title="Migrate to version 3200"
directory="profiles/migrate_to_3200"
description="RER:Bandi migrate to version 3200"
provides="Products.GenericSetup.interfaces.EXTENSION"
/>

<genericsetup:importStep
name="rer.bandi"
title="RER: Bandi configuration"
Expand All @@ -88,7 +96,7 @@
<adapter name="chiusura_procedimento_bando" factory=".indexer.chiusura_procedimento_bando" />
<adapter name="scadenza_bando" factory=".indexer.scadenza_bando" />
<adapter name="tipologia_bando" factory=".indexer.tipologia_bando" />
<adapter name="finanziatori" factory=".indexer.finanziatori" />
<adapter name="finanziato" factory=".indexer.finanziato" />
<adapter name="materie" factory=".indexer.materie" />

</configure>
33 changes: 15 additions & 18 deletions rer/bandi/indexer.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,66 +13,63 @@ def dateToDatetime(d):

@indexer(IBando)
def destinatari_bando(object, **kw):
destinatari = getattr(object, 'destinatari', [])
destinatari = getattr(object, "destinatari", [])
if not destinatari:
return []
if six.PY2:
return [x.encode('utf-8') for x in destinatari]
return [x.encode("utf-8") for x in destinatari]
return destinatari


@indexer(IBando)
def chiusura_procedimento_bando(object, **kw):

date_chiusura_procedimento_bando = getattr(
object, 'chiusura_procedimento_bando', None
object, "chiusura_procedimento_bando", None
)
if date_chiusura_procedimento_bando:
datetime_chiusura_procedimento_bando = dateToDatetime(
date_chiusura_procedimento_bando
)
else:
return DateTime('2100/12/31')
return DateTime("2100/12/31")

if datetime_chiusura_procedimento_bando:
return DateTime(datetime_chiusura_procedimento_bando)


@indexer(IBando)
def scadenza_bando(object, **kw):
datetime_scadenza_bando = getattr(object, 'scadenza_bando', None)
datetime_scadenza_bando = getattr(object, "scadenza_bando", None)
if not datetime_scadenza_bando:
return DateTime('2100/12/31')
return DateTime("2100/12/31")
zope_dt_scadenza_bando = DateTime(datetime_scadenza_bando)
if zope_dt_scadenza_bando.Time() == '00:00:00':
if zope_dt_scadenza_bando.Time() == "00:00:00":
return zope_dt_scadenza_bando + 1
else:
return zope_dt_scadenza_bando


@indexer(IBando)
def tipologia_bando(object, **kw):
tipologia = getattr(object, 'tipologia_bando', '')
tipologia = getattr(object, "tipologia_bando", "")
if six.PY2:
return tipologia.encode('utf-8')
return tipologia.encode("utf-8")
return tipologia


@indexer(IBando)
def finanziatori(object, **kw):
finanziatori = getattr(object, 'finanziatori', [])
if not finanziatori:
return []
if six.PY2:
return [x.encode('utf-8') for x in finanziatori]
return finanziatori
def finanziato(object, **kw):
finanziato = getattr(object, "finanziato", [])

return finanziato


@indexer(IBando)
def materie(object, **kw):
materie = getattr(object, 'materie', [])
materie = getattr(object, "materie", [])
if not materie:
return []
if six.PY2:
return [x.encode('utf-8') for x in materie]
return [x.encode("utf-8") for x in materie]
return materie
69 changes: 31 additions & 38 deletions rer/bandi/interfaces/bandoSchema.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,78 +19,71 @@ def checkRequiredField(value):


class IBandoSchema(model.Schema):
""" A Dexterity schema for Annoucements """

"""A Dexterity schema for Annoucements"""
finanziato = schema.Bool(
title=_("finanziatori_label", default="Financed by EU programmes"),
description=_("finanziatori_help", default=u"Seleziona questo campo se il bando è finanziato con fondi europei."),
required=False,
)

directives.widget(tipologia_bando=RadioFieldWidget)
tipologia_bando = schema.Choice(
title=_('tipologia_bando_label', default=u"Announcement type"),
description=_('tipologia_bando_help', default=''),
vocabulary='rer.bandi.tipologie.vocabulary',
title=_("tipologia_bando_label", default="Announcement type"),
description=_("tipologia_bando_help", default=""),
vocabulary="rer.bandi.tipologie.vocabulary",
required=True,
)

directives.widget(destinatari=CheckBoxFieldWidget)
destinatari = schema.List(
title=_('destinatari_label', default=u'Who can apply'),
title=_("destinatari_label", default="Who can apply"),
description=_(
'bandi_multiselect_help', default='Select one or more values.'
"bandi_multiselect_help", default="Select one or more values."
),
constraint=checkRequiredField,
required=True,
value_type=schema.Choice(
vocabulary='rer.bandi.destinatari.vocabulary'
),
)

directives.widget(finanziatori=CheckBoxFieldWidget)
finanziatori = schema.List(
title=_('finanziatori_label', default=u'Financed by EU programmes'),
description=_(
'bandi_multiselect_help', default='Select one or more values.'
),
required=False,
value_type=schema.Choice(
vocabulary='rer.bandi.finanziatori.vocabulary'
vocabulary="rer.bandi.destinatari.vocabulary"
),
)

directives.widget(materie=CheckBoxFieldWidget)
materie = schema.List(
title=_('materie_label', default=u'Topic'),
title=_("materie_label", default="Topic"),
description=_(
'bandi_multiselect_help', default='Select one or more values.'
"bandi_multiselect_help", default="Select one or more values."
),
required=False,
value_type=schema.Choice(vocabulary='rer.bandi.materie.vocabulary'),
value_type=schema.Choice(vocabulary="rer.bandi.materie.vocabulary"),
)

scadenza_bando = schema.Datetime(
title=_('scadenza_bando_label', default=u"Expiration date and time"),
title=_("scadenza_bando_label", default="Expiration date and time"),
description=_(
'scadenza_bando_help',
default=u"Deadline to participate in the announcement",
"scadenza_bando_help",
default="Deadline to participate in the announcement",
),
required=False,
)
chiusura_procedimento_bando = schema.Date(
title=_(
'chiusura_procedimento_bando_label',
default=u"Closing date procedure",
"chiusura_procedimento_bando_label",
default="Closing date procedure",
),
description=_('chiusura_procedimento_bando_help', default=u''),
description=_("chiusura_procedimento_bando_help", default=""),
required=False,
)

riferimenti_bando = RichText(
title=_('riferimenti_bando_label', default=u"References"),
description=_('riferimenti_bando_help', default=u""),
title=_("riferimenti_bando_label", default="References"),
description=_("riferimenti_bando_help", default=""),
required=False,
)

form.order_after(tipologia_bando='IRichText.text')
form.order_after(destinatari='tipologia_bando')
form.order_after(finanziatori='destinatari')
form.order_after(materie='finanziatori')
form.order_after(scadenza_bando='materie')
form.order_after(chiusura_procedimento_bando='scadenza_bando')
form.order_after(riferimenti_bando='chiusura_procedimento_bando')
form.order_after(finanziato="IRichText.text")
form.order_after(tipologia_bando="finanziato")
form.order_after(destinatari="tipologia_bando")
form.order_after(materie="destinatari")
form.order_after(scadenza_bando="materie")
form.order_after(chiusura_procedimento_bando="scadenza_bando")
form.order_after(riferimenti_bando="chiusura_procedimento_bando")
Loading

0 comments on commit b82fd60

Please sign in to comment.