Skip to content

Commit

Permalink
[feat] behavior to add field argomenti in Link CT
Browse files Browse the repository at this point in the history
  • Loading branch information
luca-bellenghi committed Dec 20, 2023
1 parent 21349b8 commit 7f7c562
Show file tree
Hide file tree
Showing 6 changed files with 67 additions and 2 deletions.
3 changes: 2 additions & 1 deletion CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ Changelog
6.1.8 (unreleased)
------------------

- Nothing changed yet.
- Add behavior aromento to Link CT
[lucabel]


6.1.7 (2023-12-20)
Expand Down
42 changes: 42 additions & 0 deletions src/design/plone/contenttypes/behaviors/argomenti.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from design.plone.contenttypes.interfaces.documento import IDocumento
from design.plone.contenttypes.interfaces.servizio import IServizio
from plone.app.contenttypes.interfaces import IDocument
from plone.app.contenttypes.interfaces import ILink
from plone.app.dexterity import textindexer
from plone.app.z3cform.widget import RelatedItemsFieldWidget
from plone.autoform import directives as form
Expand Down Expand Up @@ -68,6 +69,38 @@ class IArgomentiSchema(model.Schema):
textindexer.searchable("tassonomia_argomenti")


@provider(IFormFieldProvider)
class IArgomentiLink(model.Schema):
"""Marker interface for Argomenti"""

tassonomia_argomenti = RelationList(
title=_("tassonomia_argomenti_label", default="Argomenti"),
description=_(
"tassonomia_argomenti_help",
default="Seleziona una lista di argomenti d'interesse per questo"
" contenuto.",
),
value_type=RelationChoice(
title=_("Argomenti correlati"),
vocabulary="plone.app.vocabularies.Catalog",
),
required=False,
default=[],
)

form.widget(
"tassonomia_argomenti",
RelatedItemsFieldWidget,
vocabulary="plone.app.vocabularies.Catalog",
pattern_options={
"maximumSelectionSize": 20,
"selectableTypes": ["Pagina Argomento"],
},
)

textindexer.searchable("tassonomia_argomenti")


@provider(IFormFieldProvider)
class IArgomenti(IArgomentiSchema):
""" """
Expand Down Expand Up @@ -273,3 +306,12 @@ class ArgomentiEvento(object):

def __init__(self, context):
self.context = context


@implementer(IArgomentiLink)
@adapter(ILink)
class ArgomentiLink(object):
""""""

def __init__(self, context):
self.context = context
10 changes: 10 additions & 0 deletions src/design/plone/contenttypes/behaviors/configure.zcml
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,16 @@
for="plone.dexterity.interfaces.IDexterityContent"
marker=".argomenti.IArgomentiServizio"
/>
<plone:behavior
name="design.plone.contenttypes.behavior.argomenti_link"
title="Argomenti Link"
description="Tassonomia argomenti"
factory=".argomenti.ArgomentiLink"
provides=".argomenti.IArgomentiLink"
for="plone.dexterity.interfaces.IDexterityContent"
marker=".argomenti.IArgomentiLink"
/>

<plone:behavior
name="design.plone.contenttypes.behavior.luoghi_correlati"
title="Luoghi correlati"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<metadata>
<version>7020</version>
<version>7021</version>
<dependencies>
<dependency>profile-redturtle.bandi:default</dependency>
<dependency>profile-collective.venue:default</dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,6 @@
<element value="volto.preview_image" />
<element value="plone.translatable" />
<element value="plone.versioning" />
<element value="design.plone.contenttypes.behavior.argomenti_link" />
</property>
</object>
11 changes: 11 additions & 0 deletions src/design/plone/contenttypes/upgrades/configure.zcml
Original file line number Diff line number Diff line change
Expand Up @@ -784,4 +784,15 @@
handler=".upgrades.update_actions"
/>
</genericsetup:upgradeSteps>
<genericsetup:upgradeSteps
profile="design.plone.contenttypes:default"
source="7020"
destination="7021"
>
<genericsetup:upgradeStep
title="Add utils views in user actions"
handler=".upgrades.update_types"
/>
</genericsetup:upgradeSteps>

</configure>

0 comments on commit 7f7c562

Please sign in to comment.