Skip to content

Commit

Permalink
split news behaviors (comunicatistampa) (#273)
Browse files Browse the repository at this point in the history
* split news behaviors
* changelog
* fix test
* add subobject in comunicatostampa
* Update CHANGES.rst
  • Loading branch information
mamico authored Sep 3, 2024
1 parent b347008 commit 0fcf95f
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 12 deletions.
4 changes: 4 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ Changelog
6.2.15 (unreleased)
-------------------

- Add design.plone.contenttypes.behavior.news_base behavior (news metadata, without blocks)
[mamico]
- Add folder creation (multimedia + allegati) for "ComunicatiStampa" CT (if exists)
[mamico]
- Add "Emolumenti a carico della finanza pubblica" to Persona
Add "Dichiarazioni di insussistenza e incompatibilità" to Persona
[lucabel]
Expand Down
8 changes: 8 additions & 0 deletions src/design/plone/contenttypes/behaviors/configure.zcml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,14 @@
marker=".news_additional_fields.INewsAdditionalFields"
/>

<plone:behavior
name="design.plone.contenttypes.behavior.news_base"
title="Metadati news base (senza descrizione_estesa)"
description="Adds fields."
provides=".news_additional_fields.INewsAdditionalFieldsBase"
marker=".news_additional_fields.INewsAdditionalFieldsBase"
/>

<plone:behavior
name="design.plone.contenttypes.behavior.argomenti"
title="Argomenti"
Expand Down
25 changes: 14 additions & 11 deletions src/design/plone/contenttypes/behaviors/news_additional_fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,7 @@


@provider(IFormFieldProvider)
class INewsAdditionalFields(model.Schema):
descrizione_estesa = BlocksField(
title=_("descrizione_estesa", default="Descrizione estesa"),
required=True,
description=_(
"descrizione_estesa_help",
default="Descrizione dettagliata e completa.",
),
)

class INewsAdditionalFieldsBase(model.Schema):
numero_progressivo_cs = schema.TextLine(
title=_(
"numero_progressivo_cs_label",
Expand Down Expand Up @@ -121,10 +112,22 @@ class INewsAdditionalFields(model.Schema):
fields=["notizie_correlate"],
)
# custom fieldsets and order
form.order_before(descrizione_estesa="ILeadImageBehavior.image")
form.order_before(numero_progressivo_cs="ILeadImageBehavior.image")
form.order_before(a_cura_di="ILeadImageBehavior.image")


@provider(IFormFieldProvider)
class INewsAdditionalFields(INewsAdditionalFieldsBase):
descrizione_estesa = BlocksField(
title=_("descrizione_estesa", default="Descrizione estesa"),
required=True,
description=_(
"descrizione_estesa_help",
default="Descrizione dettagliata e completa.",
),
)

form.order_before(descrizione_estesa="ILeadImageBehavior.image")
textindexer.searchable("descrizione_estesa")


Expand Down
20 changes: 20 additions & 0 deletions src/design/plone/contenttypes/events/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,26 @@
},
],
},
"ComunicatoStampa": {
"content": [
{
"id": "multimedia",
"title": "Multimedia",
"allowed_types": (
"Image",
"Link",
),
},
{
"id": "documenti-allegati",
"title": "Documenti allegati",
"allowed_types": (
"File",
"Image",
),
},
]
},
"Persona": {
"content": [
{
Expand Down
2 changes: 1 addition & 1 deletion src/design/plone/contenttypes/tests/test_ct_news.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,11 +125,11 @@ def test_news_item_fields_default_fieldset(self):
"image_caption",
"preview_image",
"preview_caption",
"descrizione_estesa",
"numero_progressivo_cs",
"a_cura_di",
"a_cura_di_persone",
"luoghi_correlati",
"descrizione_estesa",
"tassonomia_argomenti",
"tipologia_notizia",
],
Expand Down

0 comments on commit 0fcf95f

Please sign in to comment.