From 1ac56afe20af62835e3858f4b2d7ed24c260aee5 Mon Sep 17 00:00:00 2001 From: rachidatecs Date: Tue, 13 Jun 2023 17:44:19 -0400 Subject: [PATCH] additional comments, move log statements after the actions they're logging. --- src/registrar/admin.py | 2 +- src/registrar/models/domain_application.py | 17 ++++++++++++----- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/src/registrar/admin.py b/src/registrar/admin.py index 957a51867..c8d48024b 100644 --- a/src/registrar/admin.py +++ b/src/registrar/admin.py @@ -68,7 +68,7 @@ class DomainApplicationAdmin(AuditedAdmin): ): # This is a transition annotated method in model which will throw an # error if the condition is violated. To make this work, we need to - # call it on the original object which has the right status value, + # call it on the original object which has the right status value, # but pass the current object which contains the up-to-date data # for the email. original_obj.in_review(obj) diff --git a/src/registrar/models/domain_application.py b/src/registrar/models/domain_application.py index 619557d20..5ed887a51 100644 --- a/src/registrar/models/domain_application.py +++ b/src/registrar/models/domain_application.py @@ -484,15 +484,15 @@ 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", self.submitter.email, context={"application": self}, ) + logger.info( + f"Submission confirmation email sent to: {self.submitter.email}" + ) except EmailSendingError: logger.warning("Failed to send confirmation email", exc_info=True) @@ -510,13 +510,15 @@ class DomainApplication(TimeStampedModel): ) 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}, ) + logging.info( + f"In review email sent to: {self.submitter.email}" + ) except EmailSendingError: logger.warning( "Failed to send status change (in review) email", exc_info=True @@ -572,7 +574,12 @@ class DomainApplication(TimeStampedModel): @transition(field="status", source=SUBMITTED, target=INVESTIGATING) def in_review(self, updated_domain_application): - """Investigate an application that has been submitted.""" + """Investigate an application that has been submitted. + + This method is called in admin.py on the original application + which has the correct status value, but is passed the changed + application which has the up-to-date data that we'll use + in the email.""" # When an application is moved to in review, we need to send a # confirmation email. This is a side-effect of the state transition