Skip to content

Commit

Permalink
add metadata for tipologia_notizia
Browse files Browse the repository at this point in the history
  • Loading branch information
cekk committed Oct 25, 2024
1 parent 82aecb2 commit b81e121
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/iosanita/contenttypes/indexers/configure.zcml
Original file line number Diff line number Diff line change
Expand Up @@ -68,4 +68,8 @@
factory=".taxonomies.incarico_metadata"
name="incarico_metadata"
/>
<adapter
factory=".taxonomies.tipologia_notizia_metadata"
name="tipologia_notizia_metadata"
/>
</configure>
8 changes: 8 additions & 0 deletions src/iosanita/contenttypes/indexers/taxonomies.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
)
1 change: 1 addition & 0 deletions src/iosanita/contenttypes/profiles/default/catalog.xml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
<column value="incarico_metadata" />
<column value="parliamo_di_metadata" />
<column value="a_chi_si_rivolge_tassonomia_metadata" />
<column value="tipologia_notizia_metadata" />
<column value="street"/>
<column value="zip_code"/>
<column value="city"/>
Expand Down
17 changes: 17 additions & 0 deletions src/iosanita/contenttypes/tests/test_taxonomies_custom_metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"}],
)

0 comments on commit b81e121

Please sign in to comment.