mirror of
https://github.com/cisagov/manage.get.gov.git
synced 2025-08-12 04:29:44 +02:00
Merge branch 'main' into ag/2616-populate-suborg-and-portfolio-script
This commit is contained in:
commit
3ececbbe27
1 changed files with 26 additions and 22 deletions
|
@ -837,6 +837,23 @@ class DomainAddUserView(DomainFormBaseView):
|
||||||
)
|
)
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
# Check to see if an invite has already been sent
|
||||||
|
try:
|
||||||
|
invite = DomainInvitation.objects.get(email=email, domain=self.object)
|
||||||
|
# check if the invite has already been accepted
|
||||||
|
if invite.status == DomainInvitation.DomainInvitationStatus.RETRIEVED:
|
||||||
|
add_success = False
|
||||||
|
messages.warning(
|
||||||
|
self.request,
|
||||||
|
f"{email} is already a manager for this domain.",
|
||||||
|
)
|
||||||
|
else:
|
||||||
|
add_success = False
|
||||||
|
# else if it has been sent but not accepted
|
||||||
|
messages.warning(self.request, f"{email} has already been invited to this domain")
|
||||||
|
except Exception:
|
||||||
|
logger.error("An error occured")
|
||||||
|
|
||||||
try:
|
try:
|
||||||
send_templated_email(
|
send_templated_email(
|
||||||
"emails/domain_invitation.txt",
|
"emails/domain_invitation.txt",
|
||||||
|
@ -862,17 +879,6 @@ class DomainAddUserView(DomainFormBaseView):
|
||||||
|
|
||||||
def _make_invitation(self, email_address: str, requestor: User):
|
def _make_invitation(self, email_address: str, requestor: User):
|
||||||
"""Make a Domain invitation for this email and redirect with a message."""
|
"""Make a Domain invitation for this email and redirect with a message."""
|
||||||
# Check to see if an invite has already been sent (NOTE: we do not want to create an invite just yet.)
|
|
||||||
try:
|
|
||||||
invite = DomainInvitation.objects.get(email=email_address, domain=self.object)
|
|
||||||
# that invitation already existed
|
|
||||||
if invite is not None:
|
|
||||||
messages.warning(
|
|
||||||
self.request,
|
|
||||||
f"{email_address} has already been invited to this domain.",
|
|
||||||
)
|
|
||||||
except DomainInvitation.DoesNotExist:
|
|
||||||
# Try to send the invitation. If it succeeds, add it to the DomainInvitation table.
|
|
||||||
try:
|
try:
|
||||||
self._send_domain_invitation_email(email=email_address, requestor=requestor)
|
self._send_domain_invitation_email(email=email_address, requestor=requestor)
|
||||||
except EmailSendingError:
|
except EmailSendingError:
|
||||||
|
@ -919,11 +925,9 @@ class DomainAddUserView(DomainFormBaseView):
|
||||||
role=UserDomainRole.Roles.MANAGER,
|
role=UserDomainRole.Roles.MANAGER,
|
||||||
)
|
)
|
||||||
except IntegrityError:
|
except IntegrityError:
|
||||||
# User already has the desired role! Do nothing??
|
messages.warning(self.request, f"{requested_email} is already a manager for this domain")
|
||||||
pass
|
else:
|
||||||
|
|
||||||
messages.success(self.request, f"Added user {requested_email}.")
|
messages.success(self.request, f"Added user {requested_email}.")
|
||||||
|
|
||||||
return redirect(self.get_success_url())
|
return redirect(self.get_success_url())
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue