Skip to content

Commit

Permalink
Add migration to fix urls on TranslationContext model
Browse files Browse the repository at this point in the history
  • Loading branch information
jhonatan-lopes committed Mar 19, 2024
1 parent 68ebe80 commit dfc842d
Showing 1 changed file with 25 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Generated by Django 4.2.10 on 2024-03-19 15:42

from django.db import migrations


def fix_urls_on_translation_context_model(apps, schema_editor):
TranslationContext = apps.get_model("wagtail_localize", "TranslationContext")
contexts = TranslationContext.objects.filter(path__endswith=".URL")

for context in contexts:
context.path = context.path.replace(".URL", ".external_url")
if context.field_path:
context.field_path = context.field_path.replace(".URL", ".external_url")
context.save()


class Migration(migrations.Migration):

dependencies = [
("wagtailpages", "0129_allow_spacer_on_articlepage_body"),
]

operations = [
migrations.RunPython(fix_urls_on_translation_context_model, reverse_code=migrations.RunPython.noop),
]

0 comments on commit dfc842d

Please sign in to comment.