-
Notifications
You must be signed in to change notification settings - Fork 186
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add permissions for QA and Relman signoff fixes #1171
- Loading branch information
Showing
7 changed files
with
245 additions
and
10 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
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
45 changes: 45 additions & 0 deletions
45
app/experimenter/experiments/migrations/0049_add_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,45 @@ | ||
# Generated by Django 2.1.7 on 2019-04-25 19:12 | ||
|
||
from django.db import migrations | ||
|
||
|
||
def create_permissions(apps, schema_editor): | ||
Permission = apps.get_model("auth", "Permission") | ||
ContentType = apps.get_model("contenttypes", "ContentType") | ||
Experiment = apps.get_model("experiments", "Experiment") | ||
|
||
content_type = ContentType.objects.get_for_model(Experiment) | ||
|
||
qa_permission = Permission.objects.create( | ||
codename="can_check_QA_signoff", | ||
name="Can check QA signoff box", | ||
content_type=content_type, | ||
) | ||
|
||
relman_permission = Permission.objects.create( | ||
codename="can_check_relman_signoff", | ||
name="Can check relman signoff box", | ||
content_type=content_type, | ||
) | ||
|
||
|
||
def remove_permissions(apps, schema_editor): | ||
Permission = apps.get_model("auth", "Permission") | ||
|
||
relman_signoff = Permission.objects.get( | ||
codename="can_check_relman_signoff" | ||
) | ||
relman_signoff.delete() | ||
|
||
qa_signoff = Permission.objects.get(codename="can_check_QA_signoff") | ||
qa_signoff.delete() | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
("experiments", "0048_experiment_risk_external_team_impact"), | ||
("auth", "0009_alter_user_last_name_max_length"), | ||
] | ||
|
||
operations = [migrations.RunPython(create_permissions, remove_permissions)] |
45 changes: 45 additions & 0 deletions
45
app/experimenter/experiments/migrations/0050_create_group_add_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,45 @@ | ||
from django.db import migrations | ||
|
||
|
||
def add_groups(apps, schema_editor): | ||
|
||
Group = apps.get_model("auth", "Group") | ||
Permission = apps.get_model("auth", "Permission") | ||
ContentType = apps.get_model("contenttypes", "ContentType") | ||
Experiment = apps.get_model("experiments", "Experiment") | ||
|
||
relman_signoff_group = Group.objects.create(name="Relman Signoff") | ||
qa_signoff_group = Group.objects.create(name="QA Signoff") | ||
|
||
content_type = ContentType.objects.get_for_model(Experiment) | ||
relman_permission = Permission.objects.get( | ||
content_type=content_type, codename="can_check_relman_signoff" | ||
) | ||
qa_permission = Permission.objects.get( | ||
content_type=content_type, codename="can_check_QA_signoff" | ||
) | ||
|
||
relman_signoff_group.permissions.add(relman_permission) | ||
qa_signoff_group.permissions.add(qa_permission) | ||
|
||
|
||
def remove_groups(apps, schema_editor): | ||
Group = apps.get_model("auth", "Group") | ||
|
||
relman_signoff_group = Group.objects.get(name="Relman Signoff") | ||
relman_signoff_group.delete() | ||
|
||
qa_signoff_group = Group.objects.get(name="QA Signoff") | ||
qa_signoff_group.delete() | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
("experiments", "0049_add_permissions"), | ||
("contenttypes", "0002_remove_content_type_name"), | ||
("experiments", "0048_experiment_risk_external_team_impact"), | ||
("auth", "0009_alter_user_last_name_max_length"), | ||
] | ||
|
||
operations = [migrations.RunPython(add_groups, remove_groups)] |
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
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
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