mirror of
https://github.com/cisagov/manage.get.gov.git
synced 2025-08-12 12:39:43 +02:00
formated changes
This commit is contained in:
parent
ef30e06b89
commit
68b8a6086b
1 changed files with 11 additions and 14 deletions
|
@ -836,24 +836,21 @@ class DomainAddUserView(DomainFormBaseView):
|
||||||
exc_info=True,
|
exc_info=True,
|
||||||
)
|
)
|
||||||
return None
|
return None
|
||||||
|
|
||||||
# Check to see if an invite has already been sent
|
# Check to see if an invite has already been sent
|
||||||
try:
|
try:
|
||||||
invite = DomainInvitation.objects.get(email=email, domain=self.object)
|
invite = DomainInvitation.objects.get(email=email, domain=self.object)
|
||||||
# check if the invite has already been accepted
|
# check if the invite has already been accepted
|
||||||
if invite.status == DomainInvitation.DomainInvitationStatus.RETRIEVED:
|
if invite.status == DomainInvitation.DomainInvitationStatus.RETRIEVED:
|
||||||
add_success=False
|
add_success = False
|
||||||
messages.warning(
|
messages.warning(
|
||||||
self.request,
|
self.request,
|
||||||
f"{email} is already a manager for this domain.",
|
f"{email} is already a manager for this domain.",
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
add_success=False
|
add_success = False
|
||||||
#else if it has been sent but not accepted
|
# else if it has been sent but not accepted
|
||||||
messages.warning(
|
messages.warning(self.request, f"{email} has already been invited to this domain")
|
||||||
self.request,
|
|
||||||
f"{email} has already been invited to this domain"
|
|
||||||
)
|
|
||||||
except Exception:
|
except Exception:
|
||||||
logger.error("An error occured")
|
logger.error("An error occured")
|
||||||
|
|
||||||
|
@ -879,16 +876,16 @@ class DomainAddUserView(DomainFormBaseView):
|
||||||
else:
|
else:
|
||||||
if add_success:
|
if add_success:
|
||||||
messages.success(self.request, f"{email} has been invited to this domain.")
|
messages.success(self.request, f"{email} has been invited to this domain.")
|
||||||
|
|
||||||
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."""
|
||||||
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:
|
||||||
messages.warning(self.request, "Could not send email invitation.")
|
messages.warning(self.request, "Could not send email invitation.")
|
||||||
else:
|
else:
|
||||||
# (NOTE: only create a domainInvitation if the e-mail sends correctly)
|
# (NOTE: only create a domainInvitation if the e-mail sends correctly)
|
||||||
DomainInvitation.objects.get_or_create(email=email_address, domain=self.object)
|
DomainInvitation.objects.get_or_create(email=email_address, domain=self.object)
|
||||||
return redirect(self.get_success_url())
|
return redirect(self.get_success_url())
|
||||||
|
|
||||||
def form_valid(self, form):
|
def form_valid(self, form):
|
||||||
|
@ -928,7 +925,7 @@ class DomainAddUserView(DomainFormBaseView):
|
||||||
role=UserDomainRole.Roles.MANAGER,
|
role=UserDomainRole.Roles.MANAGER,
|
||||||
)
|
)
|
||||||
except IntegrityError:
|
except IntegrityError:
|
||||||
messages.warning(self.request, f"{requested_email} already added to this domain")
|
messages.warning(self.request, f"{requested_email} already added to this domain")
|
||||||
else:
|
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