-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
OM-244 Added missing insuree rights migration
- Loading branch information
1 parent
ef6848f
commit 994c906
Showing
3 changed files
with
39 additions
and
5 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 @@ | ||
from django.db import migrations | ||
|
||
rolerights = { | ||
'Employer': ['101101', '101102', '101104'], | ||
'Inspector': ['101101'] | ||
} | ||
|
||
|
||
def add_rights(role_name, role_model, role_right_model): | ||
role = role_model.objects.get(name=role_name) | ||
for right_id in rolerights[role_name]: | ||
if not role_right_model.objects.filter(validity_to__isnull=True, role=role, right_id=right_id).exists(): | ||
_add_right_for_role(role, right_id, role_right_model) | ||
|
||
|
||
def _add_right_for_role(role, right_id, role_right_model): | ||
role_right_model.objects.create(role=role, right_id=right_id, audit_user_id=1) | ||
|
||
|
||
def on_migration(apps, schema_editor): | ||
role_model = apps.get_model("core", "role") | ||
role_right_model = apps.get_model("core", "roleright") | ||
for role in rolerights: | ||
add_rights(role, role_model, role_right_model) | ||
|
||
|
||
class Migration(migrations.Migration): | ||
dependencies = [ | ||
('msystems', '0007_add_languages'), | ||
] | ||
|
||
operations = [ | ||
migrations.RunPython(on_migration, migrations.RunPython.noop), | ||
] |
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 |
---|---|---|
@@ -1 +1 @@ | ||
from msystems.tests.saml_user_service_tests import SamlUserServiceTestCase | ||
from msystems.tests.mpass_user_service_tests import MpassUserServiceTestCase |
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