From 1f149befbd31d878fca0e6139888152225f4b3e8 Mon Sep 17 00:00:00 2001 From: cboulanger Date: Thu, 7 Sep 2023 13:12:18 +0200 Subject: [PATCH] WEB-3984 : Remove deprecated cropping annotations on banner --- CHANGES.rst | 3 +++ .../smartweb/core/profiles/default/metadata.xml | 2 +- src/imio/smartweb/core/upgrades/upgrades.py | 16 ++++++++++++++++ 3 files changed, 20 insertions(+), 1 deletion(-) diff --git a/CHANGES.rst b/CHANGES.rst index 806bfbcf..90386173 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -5,6 +5,9 @@ Changelog 1.1.24 (unreleased) ------------------- +- WEB-3984 : Remove deprecated cropping annotations on banner + [boulch, laulaz] + - WEB-3984 : Don't get banner scale anymore. Get full banner image directly [boulch, laulaz] diff --git a/src/imio/smartweb/core/profiles/default/metadata.xml b/src/imio/smartweb/core/profiles/default/metadata.xml index bb915a24..1edafd26 100644 --- a/src/imio/smartweb/core/profiles/default/metadata.xml +++ b/src/imio/smartweb/core/profiles/default/metadata.xml @@ -1,6 +1,6 @@ - 1044 + 1045 profile-plone.app.dexterity:default profile-plone.app.imagecropping:default diff --git a/src/imio/smartweb/core/upgrades/upgrades.py b/src/imio/smartweb/core/upgrades/upgrades.py index 48eff6ef..3382f13b 100644 --- a/src/imio/smartweb/core/upgrades/upgrades.py +++ b/src/imio/smartweb/core/upgrades/upgrades.py @@ -5,7 +5,9 @@ from eea.facetednavigation.interfaces import ICriteria from eea.facetednavigation.subtypes.interfaces import IFacetedNavigable from plone import api +from plone.app.imagecropping import PAI_STORAGE_KEY from plone.registry.interfaces import IRegistry +from zope.annotation.interfaces import IAnnotations from zope.component import getUtility from zope.schema import getFieldNames @@ -158,3 +160,17 @@ def to_related_contacts(context): setattr(obj, "related_contacts", [obj.related_contact]) setattr(obj, "nb_contact_by_line", 1) delattr(obj, "related_contact") + + +def remove_deprecated_cropping_annotations(context): + brains = api.content.find(portal_type="imio.smartweb.Folder") + for brain in brains: + obj = brain.getObject() + annotations = IAnnotations(obj) + scales = annotations.get(PAI_STORAGE_KEY) + if scales is not None and "banner_banner" in scales: + del scales["banner_banner"] + obj.reindexObject() + logger.info( + f"Remove deprecated banner_banner cropping annotation on {obj.absolute_url()}" + )