-
Notifications
You must be signed in to change notification settings - Fork 529
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Revert using bulk_create for new projectlocales (#3265)
- Loading branch information
Showing
2 changed files
with
52 additions
and
6 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
48 changes: 48 additions & 0 deletions
48
pontoon/base/migrations/0065_fix_projectlocale_permissions.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,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, | ||
), | ||
] |