Skip to content

Commit

Permalink
WEB-3984 : Remove deprecated cropping annotations on banner
Browse files Browse the repository at this point in the history
  • Loading branch information
boulch committed Sep 7, 2023
1 parent 14aec91 commit 1f149be
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 1 deletion.
3 changes: 3 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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]

Expand Down
2 changes: 1 addition & 1 deletion src/imio/smartweb/core/profiles/default/metadata.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version='1.0' encoding='UTF-8'?>
<metadata>
<version>1044</version>
<version>1045</version>
<dependencies>
<dependency>profile-plone.app.dexterity:default</dependency>
<dependency>profile-plone.app.imagecropping:default</dependency>
Expand Down
16 changes: 16 additions & 0 deletions src/imio/smartweb/core/upgrades/upgrades.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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()}"
)

0 comments on commit 1f149be

Please sign in to comment.