From b81e121d5d8c6814d9e275c430829de115036657 Mon Sep 17 00:00:00 2001 From: Andrea Cecchi Date: Fri, 25 Oct 2024 11:20:08 +0200 Subject: [PATCH] add metadata for tipologia_notizia --- .../contenttypes/indexers/configure.zcml | 4 ++++ .../contenttypes/indexers/taxonomies.py | 8 ++++++++ .../contenttypes/profiles/default/catalog.xml | 1 + .../tests/test_taxonomies_custom_metadata.py | 17 +++++++++++++++++ 4 files changed, 30 insertions(+) diff --git a/src/iosanita/contenttypes/indexers/configure.zcml b/src/iosanita/contenttypes/indexers/configure.zcml index 8597dc2..2958205 100644 --- a/src/iosanita/contenttypes/indexers/configure.zcml +++ b/src/iosanita/contenttypes/indexers/configure.zcml @@ -68,4 +68,8 @@ factory=".taxonomies.incarico_metadata" name="incarico_metadata" /> + diff --git a/src/iosanita/contenttypes/indexers/taxonomies.py b/src/iosanita/contenttypes/indexers/taxonomies.py index dafde36..5b4c15c 100644 --- a/src/iosanita/contenttypes/indexers/taxonomies.py +++ b/src/iosanita/contenttypes/indexers/taxonomies.py @@ -53,3 +53,11 @@ def a_chi_si_rivolge_tassonomia_metadata(context, **kw): def incarico_metadata(context, **kw): """ """ return extract_taxonomies(context=context, field="incarico", only_leaf=True) + + +@indexer(IDexterityContent) +def tipologia_notizia_metadata(context, **kw): + """ """ + return extract_taxonomies( + context=context, field="tipologia_notizia", only_leaf=True + ) diff --git a/src/iosanita/contenttypes/profiles/default/catalog.xml b/src/iosanita/contenttypes/profiles/default/catalog.xml index 204b732..925b5cd 100644 --- a/src/iosanita/contenttypes/profiles/default/catalog.xml +++ b/src/iosanita/contenttypes/profiles/default/catalog.xml @@ -44,6 +44,7 @@ + diff --git a/src/iosanita/contenttypes/tests/test_taxonomies_custom_metadata.py b/src/iosanita/contenttypes/tests/test_taxonomies_custom_metadata.py index ec8b9aa..a4ee945 100644 --- a/src/iosanita/contenttypes/tests/test_taxonomies_custom_metadata.py +++ b/src/iosanita/contenttypes/tests/test_taxonomies_custom_metadata.py @@ -87,3 +87,20 @@ def test_incarico_has_last_taxonomy_leaf_value(self): res.incarico_metadata, [{"title": "Medico", "token": "medico"}], ) + + def test_tipologia_notizia_has_last_taxonomy_leaf_value(self): + """ """ + news = api.content.create( + container=self.portal, + type="News Item", + title="xxx", + tipologia_notizia=[ + "comunicato-stampa", + ], + ) + res = api.content.find(UID=news.UID())[0] + + self.assertEqual( + res.tipologia_notizia_metadata, + [{"title": "Comunicato (stampa)", "token": "comunicato-stampa"}], + )