Skip to content

Commit

Permalink
fix default blocks
Browse files Browse the repository at this point in the history
  • Loading branch information
cekk committed Jun 12, 2023
1 parent 94f1009 commit 8933951
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions src/design/plone/policy/upgrades.py
Original file line number Diff line number Diff line change
Expand Up @@ -335,17 +335,20 @@ def to_3001(context):

def to_3100(context):
for tassonomia in TASSONOMIA_FOOTER:
brains = api.content.find(title=tassonomia['title'], object_provides=IBlocks.__identifier__)
brains = api.content.find(
title=tassonomia["title"], object_provides=IBlocks.__identifier__
)
for brain in brains:
item = brain.getObject().aq_inner
blocks = getattr(item, 'blocks', {})
blocks_layout = getattr(item, 'blocks_layout', {})
blocks = getattr(item, "blocks", {})
blocks_layout = getattr(item, "blocks_layout", {})
if blocks and not blocks_layout:
# case where document has been created without blocks, and has been modified
item.blocks_layout = {"items": [x for x in blocks.keys()]}
logger.info(f"[{brain.getPath()}] - Add blocks_layout from blocks keys. Check order.")
logger.info(
f"[{brain.getPath()}] - Add blocks_layout from blocks keys. Check order."
)
continue
if not blocks and not blocks_layout:
create_default_blocks(item)
logger.info(f"[{brain.getPath()}] - Add default blocks.")

0 comments on commit 8933951

Please sign in to comment.