diff --git a/backend/audit/views/manage_submission_access.py b/backend/audit/views/manage_submission_access.py index 1c46b31a3..dc39da384 100644 --- a/backend/audit/views/manage_submission_access.py +++ b/backend/audit/views/manage_submission_access.py @@ -206,9 +206,9 @@ def get(self, request, *args, **kwargs): report_id = kwargs["report_id"] sac = SingleAuditChecklist.objects.get(report_id=report_id) - try: - Access.objects.get(email=request.user.email, sac=sac, role=self.role) - except Access.DoesNotExist: + if not Access.objects.filter( + email=request.user.email, sac=sac, role=self.role + ).exists(): raise PermissionDenied( "Only Audit Editors may remove audit access for other Audit Editors." ) @@ -240,9 +240,9 @@ def post(self, request, *args, **kwargs): report_id = kwargs["report_id"] sac = SingleAuditChecklist.objects.get(report_id=report_id) - try: - Access.objects.get(email=request.user.email, sac=sac, role=self.role) - except Access.DoesNotExist: + if not Access.objects.filter( + email=request.user.email, sac=sac, role=self.role + ).exists(): raise PermissionDenied( "Only Audit Editors may remove audit access for other Audit Editors." )