From 2733a9045cf79f4ab8046ea2dc0409b2201cd658 Mon Sep 17 00:00:00 2001 From: CocoByte Date: Wed, 22 May 2024 15:10:40 -0600 Subject: [PATCH] restored if statement (not sure why it dissappeared) --- src/registrar/utility/email.py | 5 ++++- src/registrar/views/domain.py | 10 ++++++---- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/src/registrar/utility/email.py b/src/registrar/utility/email.py index 5f61181c7..10a4acc52 100644 --- a/src/registrar/utility/email.py +++ b/src/registrar/utility/email.py @@ -32,8 +32,9 @@ def send_templated_email( template_name and subject_template_name are relative to the same template context as Django's HTML templates. context gives additional information 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) email_body = template.render(context=context) @@ -48,7 +49,9 @@ def send_templated_email( aws_secret_access_key=settings.AWS_SECRET_ACCESS_KEY, config=settings.BOTO_CONFIG, ) + logger.info(f"An email was sent! Template name: {template_name} to {to_address}") 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 destination = {"ToAddresses": [to_address]} diff --git a/src/registrar/views/domain.py b/src/registrar/views/domain.py index cf1b24e0c..03a0849eb 100644 --- a/src/registrar/views/domain.py +++ b/src/registrar/views/domain.py @@ -778,11 +778,13 @@ class DomainAddUserView(DomainFormBaseView): """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 - messages.warning( - self.request, - f"{email_address} has already been invited to this domain.", - ) + 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: