-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #43 from openimis/release/23.10
MERGING release/23.10 into main
- Loading branch information
Showing
2 changed files
with
71 additions
and
109 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
# Generated by Django 3.2.17 on 2023-03-01 15:02 | ||
import logging | ||
|
||
from django.db import migrations | ||
|
||
from core.utils import insert_role_right_for_system, remove_role_right_for_system | ||
|
||
logger = logging.getLogger(__name__) | ||
|
||
# It is a dictionary with IsSystem values, it maps to RoleIDs: | ||
# ROLES_ID = [1, 2, 3, 5, 6, 7, 11, 12] | ||
ROLES_ID = [1, 2, 4, 16, 32, 64, 524288, 1048576] | ||
REPORT_QUERY_ROLE_ID = 131200 | ||
|
||
|
||
def add_query_rights(apps, schema_editor): | ||
""" | ||
Add gql_query_reports_perms to every role with report permission (based on existing data). | ||
""" | ||
for role in ROLES_ID: | ||
insert_role_right_for_system(role, REPORT_QUERY_ROLE_ID) | ||
|
||
|
||
def remove_query_rights(apps, schema_editor): | ||
""" | ||
Add gql_query_reports_perms to every role with report permission (based on existing data). | ||
""" | ||
for role in ROLES_ID: | ||
remove_role_right_for_system(role, REPORT_QUERY_ROLE_ID) | ||
|
||
|
||
class Migration(migrations.Migration): | ||
dependencies = [ | ||
('report', '0009_set_managed_to_true'), | ||
] | ||
|
||
operations = [ | ||
migrations.RunPython(add_query_rights, remove_query_rights), | ||
] |