From 0d3693aa16bf62131491958570aa27852365a16e Mon Sep 17 00:00:00 2001 From: Logan Bertram Date: Wed, 5 Jun 2024 16:50:44 -0400 Subject: [PATCH 1/3] Added --all option --- Dockerfile.selenium | 2 +- .../management/commands/update_access_grants.py | 14 +++++++++++--- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/Dockerfile.selenium b/Dockerfile.selenium index 5c645fb35..5e1192c53 100755 --- a/Dockerfile.selenium +++ b/Dockerfile.selenium @@ -1,4 +1,4 @@ -FROM selenium/standalone-chrome +FROM selenium/standalone-chromium ENV PYTHONUNBUFFERED 1 USER root diff --git a/apps/authorization/management/commands/update_access_grants.py b/apps/authorization/management/commands/update_access_grants.py index 798bc6d50..211bbd2ec 100644 --- a/apps/authorization/management/commands/update_access_grants.py +++ b/apps/authorization/management/commands/update_access_grants.py @@ -1,6 +1,8 @@ from django.core.management.base import BaseCommand from apps.authorization.models import DataAccessGrant from apps.dot_ext.models import Application + + class Command(BaseCommand): help = ( 'Update Access Grants Per Application.' @@ -8,20 +10,26 @@ class Command(BaseCommand): ) def add_arguments(self, parser): - parser.add_argument('--applications', help="list of applications to update " + parser.add_argument('--applications', help="List of applications to update " "id, comma separated: " - "eg. 1,2,3 ") + "eg. 1,2,3. Supersedes --all") + parser.add_argument('--all', action='store_true', help="Update access grants for all applications") + parser.set_defaults(all=False) def handle(self, *args, **options): if options['applications']: application_ids = options['applications'].split(',') + elif options['all']: + application_ids = Application.objects.values_list('id', flat=True) else: - print("You must pass at least one application to update.") + print("You must pass at least one application to update or use the --all option.") return False for app_id in application_ids: application = Application.objects.get(id=app_id) grants = DataAccessGrant.objects.filter(application=app_id) + if not grants: + continue if "ONE_TIME" in application.data_access_type: grants.delete() elif "THIRTEEN_MONTH" in application.data_access_type: From 2e1d95beb03a552741942b8071ae2f2fe16bb886 Mon Sep 17 00:00:00 2001 From: Logan Bertram Date: Wed, 5 Jun 2024 17:02:41 -0400 Subject: [PATCH 2/3] Revert dockerfile change --- Dockerfile.selenium | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile.selenium b/Dockerfile.selenium index 5e1192c53..5c645fb35 100755 --- a/Dockerfile.selenium +++ b/Dockerfile.selenium @@ -1,4 +1,4 @@ -FROM selenium/standalone-chromium +FROM selenium/standalone-chrome ENV PYTHONUNBUFFERED 1 USER root From 648aaf6f3e114d59dddcc0aa7decdd1660e71992 Mon Sep 17 00:00:00 2001 From: Logan Bertram Date: Wed, 5 Jun 2024 22:19:05 -0400 Subject: [PATCH 3/3] Removed extra lines --- apps/authorization/management/commands/update_access_grants.py | 3 --- 1 file changed, 3 deletions(-) diff --git a/apps/authorization/management/commands/update_access_grants.py b/apps/authorization/management/commands/update_access_grants.py index 211bbd2ec..a0e1bd7aa 100644 --- a/apps/authorization/management/commands/update_access_grants.py +++ b/apps/authorization/management/commands/update_access_grants.py @@ -16,7 +16,6 @@ def add_arguments(self, parser): parser.add_argument('--all', action='store_true', help="Update access grants for all applications") parser.set_defaults(all=False) - def handle(self, *args, **options): if options['applications']: application_ids = options['applications'].split(',') @@ -37,5 +36,3 @@ def handle(self, *args, **options): grant.update_expiration_date() else: continue - -