forked from HHS/TANF-app
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
3074 TDP Datafile page for DIGIT and Sys Admin groups (#3158)
* added migration and changes * 3074 corrected test * revert changes * 3074 added similar group permissions to DIGITTeam as Admin * remove logging for frontend * 3074-added permissions for System Admin
- Loading branch information
1 parent
1a3e1dc
commit abd8609
Showing
4 changed files
with
74 additions
and
7 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
58 changes: 58 additions & 0 deletions
58
tdrs-backend/tdpservice/users/migrations/0041_users_digit_group_add_datafile_permission.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,58 @@ | ||
# Generated by Django 3.2.5 on 2021-08-16 14:10 | ||
from django.contrib.auth.models import Group | ||
from django.db import migrations | ||
|
||
from tdpservice.users.permissions import ( | ||
add_permissions_q, | ||
get_permission_ids_for_model, | ||
view_permissions_q | ||
) | ||
|
||
|
||
def set_digit_team_permissions(apps, schema_editor): | ||
"""Set relevant Group Permissions for DIGIT Team group.""" | ||
digit = ( | ||
apps.get_model('auth', 'Group').objects.get(name='DIGIT Team') | ||
) | ||
|
||
stt_permissions = get_permission_ids_for_model( | ||
'stts', | ||
'stt', | ||
filters=[view_permissions_q] | ||
) | ||
|
||
|
||
datafile_permissions = get_permission_ids_for_model( | ||
'data_files', | ||
'datafile', | ||
filters=[view_permissions_q, add_permissions_q] | ||
) | ||
|
||
# Assign model permissions | ||
digit.permissions.add(*datafile_permissions, *stt_permissions) | ||
|
||
def unset_digit_team_permissions(apps, schema_editor): | ||
"""Remove all Group Permissions added to DIGIT Team.""" | ||
digit = ( | ||
apps.get_model('auth', 'Group').objects.get(name='DIGIT Team') | ||
) | ||
datafile_permissions = get_permission_ids_for_model( | ||
'data_files', | ||
'datafile', | ||
filters=[view_permissions_q, add_permissions_q] | ||
) | ||
digit.permissions.remove(*datafile_permissions) | ||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('auth', '__latest__'), | ||
('users', '0040_users_digit_group_permissions'), | ||
] | ||
|
||
operations = [ | ||
migrations.RunPython( | ||
set_digit_team_permissions, | ||
reverse_code=unset_digit_team_permissions | ||
) | ||
] |
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