From 7f7c5623933f87ec86ec581c985da48a987ed019 Mon Sep 17 00:00:00 2001 From: Luca Bellenghi Date: Wed, 20 Dec 2023 15:09:06 +0100 Subject: [PATCH] [feat] behavior to add field argomenti in Link CT --- CHANGES.rst | 3 +- .../plone/contenttypes/behaviors/argomenti.py | 42 +++++++++++++++++++ .../contenttypes/behaviors/configure.zcml | 10 +++++ .../profiles/default/metadata.xml | 2 +- .../profiles/default/types/Link.xml | 1 + .../contenttypes/upgrades/configure.zcml | 11 +++++ 6 files changed, 67 insertions(+), 2 deletions(-) diff --git a/CHANGES.rst b/CHANGES.rst index 2a8323ee..28f5ece7 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -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) diff --git a/src/design/plone/contenttypes/behaviors/argomenti.py b/src/design/plone/contenttypes/behaviors/argomenti.py index c35caa97..427410bd 100644 --- a/src/design/plone/contenttypes/behaviors/argomenti.py +++ b/src/design/plone/contenttypes/behaviors/argomenti.py @@ -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 @@ -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): """ """ @@ -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 diff --git a/src/design/plone/contenttypes/behaviors/configure.zcml b/src/design/plone/contenttypes/behaviors/configure.zcml index 204c1e03..9d00c5cb 100644 --- a/src/design/plone/contenttypes/behaviors/configure.zcml +++ b/src/design/plone/contenttypes/behaviors/configure.zcml @@ -101,6 +101,16 @@ for="plone.dexterity.interfaces.IDexterityContent" marker=".argomenti.IArgomentiServizio" /> + + - 7020 + 7021 profile-redturtle.bandi:default profile-collective.venue:default diff --git a/src/design/plone/contenttypes/profiles/default/types/Link.xml b/src/design/plone/contenttypes/profiles/default/types/Link.xml index 8aea89da..49cb09a4 100644 --- a/src/design/plone/contenttypes/profiles/default/types/Link.xml +++ b/src/design/plone/contenttypes/profiles/default/types/Link.xml @@ -12,5 +12,6 @@ + diff --git a/src/design/plone/contenttypes/upgrades/configure.zcml b/src/design/plone/contenttypes/upgrades/configure.zcml index 75f8fced..3cfeb960 100644 --- a/src/design/plone/contenttypes/upgrades/configure.zcml +++ b/src/design/plone/contenttypes/upgrades/configure.zcml @@ -784,4 +784,15 @@ handler=".upgrades.update_actions" /> + + + +