Skip to content

Commit

Permalink
Add upgrade step to list sections without hash
Browse files Browse the repository at this point in the history
This is to help debugging WEB-3995
  • Loading branch information
laulaz committed Sep 9, 2024
1 parent 0212448 commit ba7e351
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 1 deletion.
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>1061</version>
<version>1062</version>
<dependencies>
<dependency>profile-plone.app.dexterity:default</dependency>
<dependency>profile-plone.app.imagecropping:default</dependency>
Expand Down
9 changes: 9 additions & 0 deletions src/imio/smartweb/core/upgrades/configure.zcml
Original file line number Diff line number Diff line change
Expand Up @@ -891,4 +891,13 @@
/>
</genericsetup:upgradeSteps>

<genericsetup:upgradeStep
title="List sections without hash"
description=""
source="1061"
destination="1062"
handler=".upgrades.list_sections_without_hash"
profile="imio.smartweb.core:default"
/>

</configure>
18 changes: 18 additions & 0 deletions src/imio/smartweb/core/upgrades/upgrades.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

from imio.smartweb.core.browser.controlpanel import ISmartwebControlPanel
from imio.smartweb.core.contents import IPages
from imio.smartweb.core.contents.sections.views import SECTION_ITEMS_HASH_KEY
from eea.facetednavigation.interfaces import ICriteria
from eea.facetednavigation.subtypes.interfaces import IFacetedNavigable
from plone import api
Expand Down Expand Up @@ -227,3 +228,20 @@ def migrate_old_sizes_from_section_text(context):
logger.info(
f"Migrated deprecated scale from {old_scale} to {new_scale} for {obj.absolute_url()}"
)


def list_sections_without_hash(context):
with api.env.adopt_user(username="admin"):
brains = api.content.find(
portal_type=[
"imio.smartweb.SectionContact",
"imio.smartweb.SectionEvents",
"imio.smartweb.SectionNews",
]
)
for brain in brains:
obj = brain.getObject()
annotations = IAnnotations(obj)
stored_hash = annotations.get(SECTION_ITEMS_HASH_KEY)
if not stored_hash:
print(f"No Hash found for {obj.absolute_url()}")

0 comments on commit ba7e351

Please sign in to comment.