Skip to content

Commit

Permalink
Merge branch 'main' into bug_52791_change_news_type
Browse files Browse the repository at this point in the history
  • Loading branch information
luca-bellenghi authored Apr 22, 2024
2 parents 7affe3c + d7450cc commit 699514a
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 12 deletions.
11 changes: 10 additions & 1 deletion CHANGES.rst
Original file line number Diff line number Diff line change
@@ -1,13 +1,22 @@
Changelog
=========

6.2.6 (unreleased)
6.2.7 (unreleased)
------------------

- Fix change_news_type view; Taxonomy doesn't index values not present in
the taxonomy vocabulary, so we had lot of old values not indexed and not listed
as available type to change.
[lucabel]
- Do not break News serialzier if `tipologia_notizia` attribute is missing.
[cekk]


6.2.6 (2024-04-18)
------------------

- improved check on relation.
[daniele]


6.2.5 (2024-04-17)
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

setup(
name="design.plone.contenttypes",
version="6.2.6.dev0",
version="6.2.7.dev0",
description="DesignItalia contenty types",
long_description=long_description,
long_description_content_type="text/markdown",
Expand Down
2 changes: 1 addition & 1 deletion src/design/plone/contenttypes/patches/baseserializer.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def design_italia_serialize_to_json_call(self, version=None, include_items=True)
ttool[self.context.portal_type].Title(), context=self.request
)
if self.context.portal_type == "News Item":
if self.context.tipologia_notizia:
if getattr(self.context, "tipologia_notizia", ""):
taxonomy = getUtility(
ITaxonomy, name="collective.taxonomy.tipologia_notizia"
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,16 @@
class MetaTypeSerializer(object):
def get_design_meta_type(self):
ttool = api.portal.get_tool("portal_types")
if self.context.portal_type == "News Item" and self.context.tipologia_notizia:
tipologia_notizia = getattr(self.context, "tipologia_notizia", "")
if self.context.portal_type == "News Item" and tipologia_notizia:
taxonomy = getUtility(
ITaxonomy, name="collective.taxonomy.tipologia_notizia"
)
taxonomy_voc = taxonomy.makeVocabulary(self.request.get("LANGUAGE"))
if isinstance(self.context.tipologia_notizia, list):
token = self.context.tipologia_notizia[0]
if isinstance(tipologia_notizia, list):
token = tipologia_notizia[0]
else:
token = self.context.tipologia_notizia
token = tipologia_notizia
title = taxonomy_voc.inv_data.get(token, None)

if title and title.startswith(PATH_SEPARATOR):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,10 @@ def related_contents(self, field, portal_type):
)

for rel in relations:
obj = intids.queryObject(rel.from_id)
try:
obj = intids.queryObject(rel.from_id)
except: # noqa
continue
if (
obj is not None
and checkPermission("zope2.View", obj)
Expand Down
9 changes: 5 additions & 4 deletions src/design/plone/contenttypes/restapi/serializers/summary.py
Original file line number Diff line number Diff line change
Expand Up @@ -220,15 +220,16 @@ def is_get_call(self):
def get_design_meta_type(self):
ttool = api.portal.get_tool("portal_types")
if self.context.portal_type == "News Item":
if self.context.tipologia_notizia:
tipologia_notizia = getattr(self.context, "tipologia_notizia", "")
if tipologia_notizia:
taxonomy = getUtility(
ITaxonomy, name="collective.taxonomy.tipologia_notizia"
)
taxonomy_voc = taxonomy.makeVocabulary(self.request.get("LANGUAGE"))
if isinstance(self.context.tipologia_notizia, list):
token = self.context.tipologia_notizia[0]
if isinstance(tipologia_notizia, list):
token = tipologia_notizia[0]
else:
token = self.context.tipologia_notizia
token = tipologia_notizia
title = taxonomy_voc.inv_data.get(token, None)
if title:
if title.startswith(PATH_SEPARATOR):
Expand Down

0 comments on commit 699514a

Please sign in to comment.