mirror of
https://github.com/cisagov/manage.get.gov.git
synced 2025-08-18 15:34:16 +02:00
simplified conditions on save, accounting for multiple users with same email address
This commit is contained in:
parent
cc1a8fd44a
commit
ab491d1507
1 changed files with 5 additions and 11 deletions
|
@ -1439,18 +1439,12 @@ class DomainInvitationAdmin(ListHeaderAdmin):
|
||||||
Override the save_model method.
|
Override the save_model method.
|
||||||
|
|
||||||
On creation of a new domain invitation, attempt to retrieve the invitation,
|
On creation of a new domain invitation, attempt to retrieve the invitation,
|
||||||
which will be successful if a user exists for that email; otherwise, will
|
which will be successful if a single User exists for that email; otherwise, will
|
||||||
raise a RuntimeError, and in this case can continue to create the invitation.
|
just continue to create the invitation.
|
||||||
"""
|
"""
|
||||||
# NOTE: is a future ticket accounting for a 'not member of this org' scenario
|
if not change and User.objects.filter(email=obj.email).count() == 1:
|
||||||
# to mirror the logic in DomainAddUser view?
|
# Domain Invitation creation for an existing User
|
||||||
if not change: # Domain Invitation creation
|
obj.retrieve()
|
||||||
try:
|
|
||||||
User.objects.get(email=obj.email)
|
|
||||||
obj.retrieve()
|
|
||||||
except User.DoesNotExist:
|
|
||||||
# Proceed with invitation as new as exception indicates user does not exist
|
|
||||||
pass
|
|
||||||
# Call the parent save method to save the object
|
# Call the parent save method to save the object
|
||||||
super().save_model(request, obj, form, change)
|
super().save_model(request, obj, form, change)
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue