diff --git a/Taskfile.yml b/Taskfile.yml index 5985f0604..2c67784b9 100644 --- a/Taskfile.yml +++ b/Taskfile.yml @@ -95,7 +95,7 @@ tasks: desc: Restart backend web server dir: tdrs-backend cmds: - - docker-compose -f docker-compose.yml restart -d + - docker-compose -f docker-compose.yml restart backend-bash: desc: Open a shell in the backend container @@ -178,7 +178,7 @@ tasks: desc: Restart frontend web server dir: tdrs-frontend cmds: - - docker-compose -f docker-compose.yml restart -d + - docker-compose -f docker-compose.yml restart frontend-av: desc: Start frontend with optional clamav service diff --git a/tdrs-backend/tdpservice/users/migrations/0041_users_digit_group_add_datafile_permission.py b/tdrs-backend/tdpservice/users/migrations/0041_users_digit_group_add_datafile_permission.py new file mode 100644 index 000000000..67dbd70ab --- /dev/null +++ b/tdrs-backend/tdpservice/users/migrations/0041_users_digit_group_add_datafile_permission.py @@ -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 + ) + ] diff --git a/tdrs-backend/tdpservice/users/test/test_permissions.py b/tdrs-backend/tdpservice/users/test/test_permissions.py index 608305131..ae53b3cda 100644 --- a/tdrs-backend/tdpservice/users/test/test_permissions.py +++ b/tdrs-backend/tdpservice/users/test/test_permissions.py @@ -180,6 +180,8 @@ def test_digit_team_permissions(digit_team): expected_permissions = {'parsers.view_parsererror', 'parsers.view_datafilesummary', 'data_files.view_datafile', + 'data_files.add_datafile', + 'stts.view_stt', 'search_indexes.view_ssp_m3', 'search_indexes.view_tribal_tanf_t5', 'search_indexes.view_tribal_tanf_t3', @@ -200,7 +202,7 @@ def test_digit_team_permissions(digit_team): 'search_indexes.view_tanf_t4', 'search_indexes.view_ssp_m6', 'search_indexes.view_tribal_tanf_t2', - 'search_indexes.view_tanf_t6' + 'search_indexes.view_tanf_t6', } group_permissions = digit_team.get_group_permissions() assert group_permissions == expected_permissions diff --git a/tdrs-frontend/src/components/Reports/Reports.jsx b/tdrs-frontend/src/components/Reports/Reports.jsx index 1f00df2c2..82e161e37 100644 --- a/tdrs-frontend/src/components/Reports/Reports.jsx +++ b/tdrs-frontend/src/components/Reports/Reports.jsx @@ -38,6 +38,9 @@ function Reports() { // The logged in user saved in our redux `auth` state object const user = useSelector((state) => state.auth.user) const isOFAAdmin = useSelector(selectPrimaryUserRole)?.name === 'OFA Admin' + const isDIGITTeam = useSelector(selectPrimaryUserRole)?.name === 'DIGIT Team' + const isSystemAdmin = + useSelector(selectPrimaryUserRole)?.name === 'OFA System Admin' const sttList = useSelector((state) => state?.stts?.sttList) const [errorModalVisible, setErrorModalVisible] = useState(false) @@ -59,7 +62,8 @@ function Reports() { Q4: 'Quarter 4 (July - September)', } - const currentStt = isOFAAdmin ? selectedStt : userProfileStt + const currentStt = + isOFAAdmin || isDIGITTeam || isSystemAdmin ? selectedStt : userProfileStt const stt = sttList?.find((stt) => stt?.name === currentStt) @@ -68,7 +72,8 @@ function Reports() { const errorsCount = formValidation.errors - const missingStt = !isOFAAdmin && !currentStt + const missingStt = + !isOFAAdmin && !isDIGITTeam && !isSystemAdmin && !currentStt const errorsRef = useRef(null) @@ -194,7 +199,7 @@ function Reports() { ) const touchedFields = Object.keys(touched).length - const expected_fields = isOFAAdmin ? 3 : 2 + const expected_fields = isOFAAdmin || isDIGITTeam || isSystemAdmin ? 3 : 2 const errors = touchedFields === 3 ? expected_fields - form.length : 0 @@ -215,6 +220,8 @@ function Reports() { setFormValidationState, touched, isOFAAdmin, + isDIGITTeam, + isSystemAdmin, ]) return ( @@ -237,7 +244,7 @@ function Reports() { )}
- {isOFAAdmin && ( + {(isOFAAdmin || isDIGITTeam || isSystemAdmin) && (