Skip to content

Commit

Permalink
add upgrade step for pdc_desc field
Browse files Browse the repository at this point in the history
  • Loading branch information
luca-bellenghi committed Jan 12, 2024
1 parent c9f7bad commit e7a5723
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 1 deletion.
2 changes: 2 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ Changelog

- Added description to PDC fields
[pnicolli]
Added upgrade step to update PDC fields description
[lucabel]


6.1.9 (2024-01-11)
Expand Down
11 changes: 10 additions & 1 deletion src/design/plone/contenttypes/upgrades/configure.zcml
Original file line number Diff line number Diff line change
Expand Up @@ -794,5 +794,14 @@
handler=".upgrades.update_types"
/>
</genericsetup:upgradeSteps>

<genericsetup:upgradeSteps
profile="design.plone.contenttypes:default"
source="7021"
destination="7022"
>
<genericsetup:upgradeStep
title="Update PDC with new pdc_description field"
handler=".upgrades.update_pdc_with_pdc_desc"
/>
</genericsetup:upgradeSteps>
</configure>
14 changes: 14 additions & 0 deletions src/design/plone/contenttypes/upgrades/upgrades.py
Original file line number Diff line number Diff line change
Expand Up @@ -1559,3 +1559,17 @@ def has_empty_prezzo(value):
"blocks_layout": {"items": [uid]},
}
logger.info(f"Fixed {len(fixed)} Events.")


def update_pdc_with_pdc_desc(context):
brains = api.content.find(portal_type="PuntoDiContatto")
logger.info(f"Found {len(brains)} PuntoDiContatto content type")
for brain in brains:
pdc = brain.getObject()
value_punto_contatto = getattr(pdc, "value_punto_contatto", [])
if value_punto_contatto:
for v in value_punto_contatto:
if not v.get("pdc_desc", None):
v["pdc_desc"] = None
logger.info(f"Set pdc_desc for {pdc.absolute_url()}")
logger.info("Ends of update")

0 comments on commit e7a5723

Please sign in to comment.