Merge branch 'main' into dk/661-other-contacts

This commit is contained in:
David Kennedy 2024-01-05 06:13:06 -05:00
commit 185c1f0cb6
No known key found for this signature in database
GPG key ID: 6528A5386E66B96B
15 changed files with 791 additions and 330 deletions

View file

@ -570,17 +570,25 @@ class DomainApplication(TimeStampedModel):
return not self.approved_domain.is_active()
return True
def _send_status_update_email(self, new_status, email_template, email_template_subject):
"""Send a atatus update email to the submitter.
def _send_status_update_email(self, new_status, email_template, email_template_subject, send_email=True):
"""Send a status update email to the submitter.
The email goes to the email address that the submitter gave as their
contact information. If there is not submitter information, then do
nothing.
send_email: bool -> Used to bypass the send_templated_email function, in the event
we just want to log that an email would have been sent, rather than actually sending one.
"""
if self.submitter is None or self.submitter.email is None:
logger.warning(f"Cannot send {new_status} email, no submitter email address.")
return
return None
if not send_email:
logger.info(f"Email was not sent. Would send {new_status} email: {self.submitter.email}")
return None
try:
send_templated_email(
email_template,
@ -684,7 +692,7 @@ class DomainApplication(TimeStampedModel):
],
target=ApplicationStatus.APPROVED,
)
def approve(self):
def approve(self, send_email=True):
"""Approve an application that has been submitted.
This has substantial side-effects because it creates another database
@ -713,6 +721,7 @@ class DomainApplication(TimeStampedModel):
"application approved",
"emails/status_change_approved.txt",
"emails/status_change_approved_subject.txt",
send_email,
)
@transition(