diff --git a/course_discovery/apps/ietf_language_tags/migrations/0006_auto_20231016_1044.py b/course_discovery/apps/ietf_language_tags/migrations/0006_auto_20231016_1044.py new file mode 100644 index 00000000000..100b367c7fc --- /dev/null +++ b/course_discovery/apps/ietf_language_tags/migrations/0006_auto_20231016_1044.py @@ -0,0 +1,33 @@ +# Generated by Django 3.2.22 on 2023-10-16 10:44 + +from django.db import migrations + +LANGTAGS = ( + ('Arabic', 'ar'), + ('French', 'fr'), + ('German', 'de'), + ('Portuguese', 'pt'), + ('Spanish', 'es'), +) + +def add_languages_tag(apps, schema_editor): # pylint: disable=unused-argument + LanguageTag = apps.get_model('ietf_language_tags', 'LanguageTag') + LanguageTagTranslation = apps.get_model('ietf_language_tags', 'LanguageTagTranslation') + + for name, code in LANGTAGS: + LanguageTag.objects.update_or_create(code=code, defaults={'name': name}) + LanguageTagTranslation.objects.update_or_create( + master=LanguageTag.objects.get(code=code), + language_code='en', + defaults={'name_t': name} + ) + +class Migration(migrations.Migration): + + dependencies = [ + ('ietf_language_tags', '0005_add_telugu_lan_tag'), + ] + + operations = [ + migrations.RunPython(add_languages_tag, migrations.RunPython.noop), + ]