mirror of
https://github.com/cisagov/manage.get.gov.git
synced 2025-05-31 09:43:54 +02:00
Add logging, templatize SUMMARY in email templates, templatize complete_application in tests, to integrate FSM inspect the status change that was made in the admin view here and call the transition method that's now defined in the model
This commit is contained in:
parent
54efe9ee32
commit
f3bf3f9e66
9 changed files with 190 additions and 329 deletions
|
@ -484,6 +484,9 @@ class DomainApplication(TimeStampedModel):
|
|||
)
|
||||
return
|
||||
try:
|
||||
logger.info(
|
||||
f"Submission confirmation email sent to: {self.submitter.email}"
|
||||
)
|
||||
send_templated_email(
|
||||
"emails/submission_confirmation.txt",
|
||||
"emails/submission_confirmation_subject.txt",
|
||||
|
@ -493,6 +496,32 @@ class DomainApplication(TimeStampedModel):
|
|||
except EmailSendingError:
|
||||
logger.warning("Failed to send confirmation email", exc_info=True)
|
||||
|
||||
def _send_in_review_email(self):
|
||||
"""Send an email that this application is now in review.
|
||||
|
||||
The email goes to the email address that the submitter gave as their
|
||||
contact information. If there is not submitter information, then do
|
||||
nothing.
|
||||
"""
|
||||
if self.submitter is None or self.submitter.email is None:
|
||||
logger.warning(
|
||||
"Cannot send status change (in review) email,"
|
||||
"no submitter email address."
|
||||
)
|
||||
return
|
||||
try:
|
||||
logging.info(f"In review email sent to: {self.submitter.email}")
|
||||
send_templated_email(
|
||||
"emails/status_change_in_review.txt",
|
||||
"emails/status_change_in_review_subject.txt",
|
||||
self.submitter.email,
|
||||
context={"application": self},
|
||||
)
|
||||
except EmailSendingError:
|
||||
logger.warning(
|
||||
"Failed to send status change (in review) email", exc_info=True
|
||||
)
|
||||
|
||||
@transition(field="status", source=[STARTED, WITHDRAWN], target=SUBMITTED)
|
||||
def submit(self):
|
||||
"""Submit an application that is started."""
|
||||
|
@ -541,6 +570,14 @@ class DomainApplication(TimeStampedModel):
|
|||
user=self.creator, domain=created_domain, role=UserDomainRole.Roles.ADMIN
|
||||
)
|
||||
|
||||
@transition(field="status", source=SUBMITTED, target=INVESTIGATING)
|
||||
def in_review(self, updated_domain_application):
|
||||
"""Investigate an application that has been submitted."""
|
||||
|
||||
# When an application is moved to in review, we need to send a
|
||||
# confirmation email. This is a side-effect of the state transition
|
||||
updated_domain_application._send_in_review_email()
|
||||
|
||||
# ## Form policies ###
|
||||
#
|
||||
# These methods control what questions need to be answered by applicants
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue