зеркало из https://github.com/mozilla/pontoon.git
Revert using bulk_create for new projectlocales (#3265)
This commit is contained in:
Родитель
c73f1aa762
Коммит
7746964827
|
@ -182,12 +182,10 @@ def manage_project(request, slug=None, template="admin_project.html"):
|
|||
.delete()
|
||||
)
|
||||
|
||||
project_locales = [
|
||||
ProjectLocale(project=project, locale=locale) for locale in locales
|
||||
]
|
||||
ProjectLocale.objects.bulk_create(
|
||||
project_locales, ignore_conflicts=True
|
||||
)
|
||||
for locale in locales:
|
||||
# The implicit pre_save and post_save signals sent here are required
|
||||
# to maintain django-guardian permissions.
|
||||
ProjectLocale.objects.get_or_create(project=project, locale=locale)
|
||||
|
||||
project_locales = ProjectLocale.objects.filter(project=project)
|
||||
|
||||
|
|
|
@ -0,0 +1,48 @@
|
|||
from django.db import migrations
|
||||
|
||||
from pontoon.base.models import ProjectLocale
|
||||
from pontoon.base.signals import assign_group_permissions, create_group
|
||||
|
||||
|
||||
def fix_projectlocale_permissions(apps, schema_editor):
|
||||
for project, locale in [
|
||||
("common-voice", "cdo"),
|
||||
("common-voice", "dar"),
|
||||
("common-voice", "nqo"),
|
||||
("common-voice", "shn"),
|
||||
("firefox-bridge", "de"),
|
||||
("firefox-bridge", "fr"),
|
||||
("firefox-bridge", "it"),
|
||||
("firefox-multi-account-containers", "fur"),
|
||||
("firefox-profiler", "en-CA"),
|
||||
("firefox-profiler", "fur"),
|
||||
("firefox-profiler", "tr"),
|
||||
]:
|
||||
try:
|
||||
project_locale = ProjectLocale.objects.get(
|
||||
project__slug=project, locale__code=locale
|
||||
)
|
||||
create_group(
|
||||
project_locale,
|
||||
"translators",
|
||||
["can_translate_project_locale"],
|
||||
f"{project}/{locale}",
|
||||
)
|
||||
assign_group_permissions(
|
||||
project_locale, "translators", ["can_translate_project_locale"]
|
||||
)
|
||||
except ProjectLocale.DoesNotExist:
|
||||
pass
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
dependencies = [
|
||||
("base", "0064_populate_unique_id"),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.RunPython(
|
||||
code=fix_projectlocale_permissions,
|
||||
reverse_code=migrations.RunPython.noop,
|
||||
),
|
||||
]
|
Загрузка…
Ссылка в новой задаче