From 81aa2cd2bf3db5ea9e6e70d57ffa17c3aafd5c6b Mon Sep 17 00:00:00 2001 From: Johannes Raggam Date: Fri, 24 Nov 2023 19:04:16 +0100 Subject: [PATCH] Fix changed behavior and marker interfaces for plone.leadimage and plone.richtext. See: https://github.com/plone/plone.app.contenttypes/pull/480 --- news/133.bugfix | 3 +++ src/plone/volto/browser/migrate_richtext.py | 6 +++--- src/plone/volto/scripts/add_image_field_metadata.py | 4 ++-- 3 files changed, 8 insertions(+), 5 deletions(-) create mode 100644 news/133.bugfix diff --git a/news/133.bugfix b/news/133.bugfix new file mode 100644 index 00000000..5b0fac50 --- /dev/null +++ b/news/133.bugfix @@ -0,0 +1,3 @@ +Fix changed behavior and marker interfaces for plone.leadimage and plone.richtext. +See: https://github.com/plone/plone.app.contenttypes/pull/480 +[thet] diff --git a/src/plone/volto/browser/migrate_richtext.py b/src/plone/volto/browser/migrate_richtext.py index c0e74c8c..82c09d3c 100644 --- a/src/plone/volto/browser/migrate_richtext.py +++ b/src/plone/volto/browser/migrate_richtext.py @@ -1,7 +1,7 @@ from logging import getLogger from operator import itemgetter from plone import api -from plone.app.contenttypes.behaviors.leadimage import ILeadImage +from plone.app.contenttypes.behaviors.leadimage import ILeadImageBehavior from plone.app.textfield.value import RichTextValue from Products.Five import BrowserView from uuid import uuid4 @@ -102,7 +102,7 @@ def migrate_richtext_to_blocks( blocks[uuid] = {"@type": "description"} blocks_layout["items"].append(uuid) - if ILeadImage(obj, None) and ILeadImage(obj).image: + if ILeadImageBehavior(obj, None) and ILeadImageBehavior(obj).image: uuid = str(uuid4()) blocks[uuid] = {"@type": "leadimage"} blocks_layout["items"].append(uuid) @@ -161,7 +161,7 @@ def get_blocks_from_richtext( def types_with_blocks(): - """A list of content types with volto.blocks behavior""" + """A list of content types with volto.blocks behavior.""" portal_types = api.portal.get_tool("portal_types") results = [] for fti in portal_types.listTypeInfo(): diff --git a/src/plone/volto/scripts/add_image_field_metadata.py b/src/plone/volto/scripts/add_image_field_metadata.py index ce2a860d..867c93d4 100644 --- a/src/plone/volto/scripts/add_image_field_metadata.py +++ b/src/plone/volto/scripts/add_image_field_metadata.py @@ -2,7 +2,7 @@ bin/instance -O Plone run scripts/add_image_field_metadata.py """ from plone import api -from plone.app.contenttypes.behaviors.leadimage import ILeadImageBehavior +from plone.app.contenttypes.behaviors.leadimage import ILeadImage from plone.volto.behaviors.preview import IPreview from plone.volto.scripts.utils import print_info @@ -12,7 +12,7 @@ catalog = api.portal.get_tool("portal_catalog") with api.env.adopt_roles(["Manager"]): - images = api.content.find(object_provides=ILeadImageBehavior.__identifier__) + images = api.content.find(object_provides=ILeadImage.__identifier__) preview_images = api.content.find(object_provides=IPreview.__identifier__) brains = images + preview_images