forked from mozilla/pontoon
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update UXActionLog records (mozilla#3283)
- Loading branch information
Showing
1 changed file
with
34 additions
and
0 deletions.
There are no files selected for viewing
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,34 @@ | ||
# Generated by Django 4.2.11 on 2024-07-24 18:49 | ||
|
||
from django.db import migrations | ||
|
||
|
||
def update_locale_code(apps, schema_editor): | ||
UXActionLog = apps.get_model("uxactionlog", "UXActionLog") | ||
Locale = apps.get_model("base", "Locale") | ||
|
||
for log in UXActionLog.objects.filter(action_type="LLM Dropdown Select"): | ||
data = log.data | ||
if "targetLanguage" in data: | ||
locale_name = data.pop("targetLanguage") | ||
locale = Locale.objects.filter(name=locale_name).first() | ||
data["localeCode"] = locale.code | ||
log.data = data | ||
log.save() | ||
|
||
|
||
class Migration(migrations.Migration): | ||
dependencies = [ | ||
("uxactionlog", "0001_initial"), | ||
( | ||
"base", | ||
"0001_squashed_0154_auto_20200206_1736", | ||
), # Ensure the Locale model's migration is applied first | ||
] | ||
|
||
operations = [ | ||
migrations.RunPython( | ||
code=update_locale_code, | ||
reverse_code=migrations.RunPython.noop, | ||
), | ||
] |