From e7dc08e8e74a8d1eebdc61656e2949c1028b8313 Mon Sep 17 00:00:00 2001 From: Tim Ballard <1425377+timoballard@users.noreply.github.com> Date: Fri, 12 Jan 2024 12:56:36 -0600 Subject: [PATCH] Resolve new User Accesses immediately, if possible (#3194) * use create fn to create Access objects * case insensitive email match * rm debug print statement --- backend/audit/models/access.py | 2 +- backend/audit/views/manage_submission_access.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/backend/audit/models/access.py b/backend/audit/models/access.py index 4527c4b913..2ed076f37e 100644 --- a/backend/audit/models/access.py +++ b/backend/audit/models/access.py @@ -32,7 +32,7 @@ def create(self, **obj_data): # try to pair this Access with an actual User object if we have one for this email address if obj_data["email"]: try: - acc_user = User.objects.get(email=obj_data["email"]) + acc_user = User.objects.get(email__iexact=obj_data["email"]) # if we don't have a User for this email, leave it as None (unclaimed Access) except User.DoesNotExist: acc_user = None diff --git a/backend/audit/views/manage_submission_access.py b/backend/audit/views/manage_submission_access.py index efbc455c65..397b8c9c3e 100644 --- a/backend/audit/views/manage_submission_access.py +++ b/backend/audit/views/manage_submission_access.py @@ -19,7 +19,7 @@ def _get_friendly_role(role): def _create_and_save_access(sac, role, fullname, email): - Access(sac=sac, role=role, fullname=fullname, email=email).save() + Access.objects.create(sac=sac, role=role, fullname=fullname, email=email) class ChangeAccessForm(forms.Form):