-
Notifications
You must be signed in to change notification settings - Fork 153
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add migration to fix urls on TranslationContext model
- Loading branch information
1 parent
68ebe80
commit dfc842d
Showing
1 changed file
with
25 additions
and
0 deletions.
There are no files selected for viewing
25 changes: 25 additions & 0 deletions
25
network-api/networkapi/wagtailpages/migrations/0130_fix_urls_on_translation_context_model.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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), | ||
] |