restored if statement (not sure why it dissappeared)

This commit is contained in:
CocoByte 2024-05-22 15:10:40 -06:00
parent 5462335416
commit 2733a9045c
No known key found for this signature in database
GPG key ID: BBFAA2526384C97F
2 changed files with 10 additions and 5 deletions

View file

@ -32,8 +32,9 @@ def send_templated_email(
template_name and subject_template_name are relative to the same template template_name and subject_template_name are relative to the same template
context as Django's HTML templates. context gives additional information context as Django's HTML templates. context gives additional information
that the template may use. that the template may use.
Raises EmailSendingError if SES client could not be accessed
""" """
logger.info(f"An email was sent! Template name: {template_name} to {to_address}")
template = get_template(template_name) template = get_template(template_name)
email_body = template.render(context=context) email_body = template.render(context=context)
@ -48,7 +49,9 @@ def send_templated_email(
aws_secret_access_key=settings.AWS_SECRET_ACCESS_KEY, aws_secret_access_key=settings.AWS_SECRET_ACCESS_KEY,
config=settings.BOTO_CONFIG, config=settings.BOTO_CONFIG,
) )
logger.info(f"An email was sent! Template name: {template_name} to {to_address}")
except Exception as exc: except Exception as exc:
logger.debug(f"E-mail unable to send! Could not access the SES client.")
raise EmailSendingError("Could not access the SES client.") from exc raise EmailSendingError("Could not access the SES client.") from exc
destination = {"ToAddresses": [to_address]} destination = {"ToAddresses": [to_address]}

View file

@ -778,11 +778,13 @@ class DomainAddUserView(DomainFormBaseView):
"""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.) # Check to see if an invite has already been sent (NOTE: we do not want to create an invite just yet.)
try: try:
invite = DomainInvitation.objects.get(email=email_address, domain=self.object)
# that invitation already existed # that invitation already existed
messages.warning( if invite is not None:
self.request, messages.warning(
f"{email_address} has already been invited to this domain.", self.request,
) f"{email_address} has already been invited to this domain.",
)
except DomainInvitation.DoesNotExist: except DomainInvitation.DoesNotExist:
# Try to send the invitation. If it succeeds, add it to the DomainInvitation table. # Try to send the invitation. If it succeeds, add it to the DomainInvitation table.
try: try: