Skip to content

Commit

Permalink
Fix previous migration and modify 0084
Browse files Browse the repository at this point in the history
  • Loading branch information
Gerrit Vermeulen committed Nov 19, 2024
1 parent f274475 commit c3b8b9f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 17 deletions.
2 changes: 1 addition & 1 deletion home/migrations/0083_alter_contentpage_whatsapp_body.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def list_string_to_action(block_value):

class ListStringToActionOperation(BaseBlockOperation):
def apply(self, block_value):
list_string_to_action(block_value) # this is wrong, there should be a return
return list_string_to_action(block_value)

@property
def operation_name_fragment(self):
Expand Down
20 changes: 4 additions & 16 deletions home/migrations/0084_alter_contentpage_whatsapp_body.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,34 +3,22 @@

from wagtail.blocks.migrations.migrate_operation import MigrateStreamData
from wagtail.blocks.migrations.operations import BaseBlockOperation
from wagtail.blocks.migrations.utils import formatted_list_child_generator
from django.db import migrations


def list_string_to_action(block_value):
# formatted_list_child_generator requires at least one item
def list_items_to_empty(block_value):
if not block_value:
return []
new_list = []
for list_item in formatted_list_child_generator(block_value):
print(f"list_item {list_item}")
new_list.append(
{
"type": "next_message",
"id": list_item["id"],
"value": {"title": list_item["value"]},
}
)
return new_list
return block_value


class ListItemsToEmptyOperation(BaseBlockOperation):
def apply(self, block_value):
return list_string_to_action(block_value)
return list_items_to_empty(block_value)

@property
def operation_name_fragment(self):
return "convert_list_string_to_action_2"
return "convert_list_items_to_empty"


class Migration(migrations.Migration):
Expand Down

0 comments on commit c3b8b9f

Please sign in to comment.