diff --git a/docs/developer/generating-emails-guide.md b/docs/developer/generating-emails-guide.md index 383fc31ac..0a97a8bc6 100644 --- a/docs/developer/generating-emails-guide.md +++ b/docs/developer/generating-emails-guide.md @@ -21,28 +21,6 @@ - Notes: Subject line of the "Domain Request Withdrawn" email - [Email Content](https://github.com/cisagov/manage.get.gov/blob/main/src/registrar/templates/emails/domain_request_withdrawn_subject.txt) -## Status Change Action Needed -- Starting Location: Django Admin -- Workflow: Analyst Admin -- Workflow Step: Click "Domain applications" -> Click an application with a status of "in review" or "rejected" -> Click status dropdown -> (select "action needed") -> click "Save" -- Notes: Note that this will send an email to the submitter (email listed on Your Contact Information). To test this with your own email, you need to create an application, set the status to either "in review" or "rejected" (and click save), then set the status to "action needed". This will send you an email. -- [Email Content](https://github.com/cisagov/manage.get.gov/blob/main/src/registrar/templates/emails/status_change_action_needed.txt) - -### Status Change Action Needed Subject -- Notes: Subject line of the "Status Change Action Needed" email -- [Email Content](https://github.com/cisagov/manage.get.gov/blob/main/src/registrar/templates/emails/status_change_action_needed_subject.txt) - -## Status Change in Review -- Starting Location: Django Admin -- Workflow: Analyst Admin -- Workflow Step: Click "Domain applications" -> Click an application with a status of "submitted" -> Click status dropdown -> (select "In review") -> click "Save" -- Notes: Note that this will send an email to the submitter (email listed on Your Contact Information). To test this with your own email, you need to create an application, then set the status to "In review". This will send you an email. -- [Email Content](https://github.com/cisagov/manage.get.gov/blob/main/src/registrar/templates/emails/status_change_approved.txt) - -### Status Change in Review Subject -- Notes: This is the subject line of the "Status Change In Review" email -- [Email Content](https://github.com/cisagov/manage.get.gov/blob/main/src/registrar/templates/emails/status_change_in_review_subject.txt) - ## Status Change Approved - Starting Location: Django Admin - Workflow: Analyst Admin diff --git a/src/registrar/models/domain_application.py b/src/registrar/models/domain_application.py index 178a140a4..196449bfa 100644 --- a/src/registrar/models/domain_application.py +++ b/src/registrar/models/domain_application.py @@ -653,13 +653,11 @@ class DomainApplication(TimeStampedModel): def in_review(self): """Investigate an application that has been submitted. - As a side effect, an email notification is sent.""" - - self._send_status_update_email( - "application in review", - "emails/status_change_in_review.txt", - "emails/status_change_in_review_subject.txt", - ) + This action is logged.""" + literal = DomainApplication.ApplicationStatus.IN_REVIEW + # Check if the tuple exists, then grab its value + in_review = literal if literal is not None else "In Review" + logger.info(f"A status change occurred. {self} was changed to '{in_review}'") @transition( field="status", @@ -674,13 +672,11 @@ class DomainApplication(TimeStampedModel): def action_needed(self): """Send back an application that is under investigation or rejected. - As a side effect, an email notification is sent.""" - - self._send_status_update_email( - "action needed", - "emails/status_change_action_needed.txt", - "emails/status_change_action_needed_subject.txt", - ) + This action is logged.""" + literal = DomainApplication.ApplicationStatus.ACTION_NEEDED + # Check if the tuple is setup correctly, then grab its value + action_needed = literal if literal is not None else "Action Needed" + logger.info(f"A status change occurred. {self} was changed to '{action_needed}'") @transition( field="status", diff --git a/src/registrar/templates/emails/status_change_action_needed.txt b/src/registrar/templates/emails/status_change_action_needed.txt deleted file mode 100644 index 27886115d..000000000 --- a/src/registrar/templates/emails/status_change_action_needed.txt +++ /dev/null @@ -1,42 +0,0 @@ -{% autoescape off %}{# In a text file, we don't want to have HTML entities escaped #} -Hi {{ application.submitter.first_name }}. - -We've identified an action needed to complete the review of your .gov domain request. - -DOMAIN REQUESTED: {{ application.requested_domain.name }} -REQUEST RECEIVED ON: {{ application.submission_date|date }} -REQUEST #: {{ application.id }} -STATUS: Action needed - - -NEED TO MAKE CHANGES? - -If you need to change your request you have to first withdraw it. Once you -withdraw the request you can edit it and submit it again. Changing your request -might add to the wait time. Learn more about withdrawing your request. -. - - -NEXT STEPS - -- You will receive a separate email from our team that provides details about the action needed. -You may need to update your application or provide additional information. - -- If you do not receive a separate email with these details within one business day, please contact us: - - - -THANK YOU - -.Gov helps the public identify official, trusted information. Thank you for -requesting a .gov domain. - ----------------------------------------------------------------- - -{% include 'emails/includes/application_summary.txt' %} ----------------------------------------------------------------- - -The .gov team -Contact us: -Visit -{% endautoescape %} diff --git a/src/registrar/templates/emails/status_change_action_needed_subject.txt b/src/registrar/templates/emails/status_change_action_needed_subject.txt deleted file mode 100644 index eac2bc2fc..000000000 --- a/src/registrar/templates/emails/status_change_action_needed_subject.txt +++ /dev/null @@ -1 +0,0 @@ -Action needed for your .gov domain request \ No newline at end of file diff --git a/src/registrar/templates/emails/status_change_in_review.txt b/src/registrar/templates/emails/status_change_in_review.txt deleted file mode 100644 index d013eb473..000000000 --- a/src/registrar/templates/emails/status_change_in_review.txt +++ /dev/null @@ -1,43 +0,0 @@ -{% autoescape off %}{# In a text file, we don't want to have HTML entities escaped #} -Hi {{ application.submitter.first_name }}. - -Your .gov domain request is being reviewed. - -DOMAIN REQUESTED: {{ application.requested_domain.name }} -REQUEST RECEIVED ON: {{ application.submission_date|date }} -REQUEST #: {{ application.id }} -STATUS: In review - - -NEED TO MAKE CHANGES? - -If you need to change your request you have to first withdraw it. Once you -withdraw the request you can edit it and submit it again. Changing your request -might add to the wait time. Learn more about withdrawing your request. -. - - -NEXT STEPS - -- We’re reviewing your request. This usually takes 20 business days. - -- You can check the status of your request at any time. - - -- We’ll email you with questions or when we complete our review. - - -THANK YOU - -.Gov helps the public identify official, trusted information. Thank you for -requesting a .gov domain. - ----------------------------------------------------------------- - -{% include 'emails/includes/application_summary.txt' %} ----------------------------------------------------------------- - -The .gov team -Contact us: -Visit -{% endautoescape %} diff --git a/src/registrar/templates/emails/status_change_in_review_subject.txt b/src/registrar/templates/emails/status_change_in_review_subject.txt deleted file mode 100644 index e4e43138b..000000000 --- a/src/registrar/templates/emails/status_change_in_review_subject.txt +++ /dev/null @@ -1 +0,0 @@ -Your .gov domain request is being reviewed \ No newline at end of file diff --git a/src/registrar/tests/test_admin.py b/src/registrar/tests/test_admin.py index 8dded9de9..f7b1ef06e 100644 --- a/src/registrar/tests/test_admin.py +++ b/src/registrar/tests/test_admin.py @@ -457,44 +457,6 @@ class TestDomainApplicationAdmin(MockEppLib): self.assertEqual(len(self.mock_client.EMAILS_SENT), 1) - @boto3_mocking.patching - def test_save_model_sends_in_review_email(self): - # make sure there is no user with this email - EMAIL = "mayor@igorville.gov" - User.objects.filter(email=EMAIL).delete() - - with boto3_mocking.clients.handler_for("sesv2", self.mock_client): - with less_console_noise(): - # Create a sample application - application = completed_application(status=DomainApplication.ApplicationStatus.SUBMITTED) - - # Create a mock request - request = self.factory.post("/admin/registrar/domainapplication/{}/change/".format(application.pk)) - - # Modify the application's property - application.status = DomainApplication.ApplicationStatus.IN_REVIEW - - # Use the model admin's save_model method - self.admin.save_model(request, application, form=None, change=True) - - # Access the arguments passed to send_email - call_args = self.mock_client.EMAILS_SENT - kwargs = call_args[0]["kwargs"] - - # Retrieve the email details from the arguments - from_email = kwargs.get("FromEmailAddress") - to_email = kwargs["Destination"]["ToAddresses"][0] - email_content = kwargs["Content"] - email_body = email_content["Simple"]["Body"]["Text"]["Data"] - - # Assert or perform other checks on the email details - expected_string = "Your .gov domain request is being reviewed." - self.assertEqual(from_email, settings.DEFAULT_FROM_EMAIL) - self.assertEqual(to_email, EMAIL) - self.assertIn(expected_string, email_body) - - self.assertEqual(len(self.mock_client.EMAILS_SENT), 1) - @boto3_mocking.patching def test_save_model_sends_approved_email(self): # make sure there is no user with this email @@ -556,44 +518,6 @@ class TestDomainApplicationAdmin(MockEppLib): # Test that approved domain exists and equals requested domain self.assertEqual(application.requested_domain.name, application.approved_domain.name) - @boto3_mocking.patching - def test_save_model_sends_action_needed_email(self): - # make sure there is no user with this email - EMAIL = "mayor@igorville.gov" - User.objects.filter(email=EMAIL).delete() - - with boto3_mocking.clients.handler_for("sesv2", self.mock_client): - with less_console_noise(): - # Create a sample application - application = completed_application(status=DomainApplication.ApplicationStatus.IN_REVIEW) - - # Create a mock request - request = self.factory.post("/admin/registrar/domainapplication/{}/change/".format(application.pk)) - - # Modify the application's property - application.status = DomainApplication.ApplicationStatus.ACTION_NEEDED - - # Use the model admin's save_model method - self.admin.save_model(request, application, form=None, change=True) - - # Access the arguments passed to send_email - call_args = self.mock_client.EMAILS_SENT - kwargs = call_args[0]["kwargs"] - - # Retrieve the email details from the arguments - from_email = kwargs.get("FromEmailAddress") - to_email = kwargs["Destination"]["ToAddresses"][0] - email_content = kwargs["Content"] - email_body = email_content["Simple"]["Body"]["Text"]["Data"] - - # Assert or perform other checks on the email details - expected_string = "We've identified an action needed to complete the review of your .gov domain request." - self.assertEqual(from_email, settings.DEFAULT_FROM_EMAIL) - self.assertEqual(to_email, EMAIL) - self.assertIn(expected_string, email_body) - - self.assertEqual(len(self.mock_client.EMAILS_SENT), 1) - @boto3_mocking.patching def test_save_model_sends_rejected_email(self): # make sure there is no user with this email diff --git a/src/registrar/tests/test_models.py b/src/registrar/tests/test_models.py index 672b8f465..1f591a5bb 100644 --- a/src/registrar/tests/test_models.py +++ b/src/registrar/tests/test_models.py @@ -268,14 +268,12 @@ class TestDomainApplication(TestCase): (self.ineligible_application, TransitionNotAllowed), ] - with boto3_mocking.clients.handler_for("sesv2", self.mock_client): - with less_console_noise(): - for application, exception_type in test_cases: - with self.subTest(application=application, exception_type=exception_type): - try: - application.action_needed() - except TransitionNotAllowed: - self.fail("TransitionNotAllowed was raised, but it was not expected.") + for application, exception_type in test_cases: + with self.subTest(application=application, exception_type=exception_type): + try: + application.action_needed() + except TransitionNotAllowed: + self.fail("TransitionNotAllowed was raised, but it was not expected.") def test_action_needed_transition_not_allowed(self): """ @@ -288,12 +286,10 @@ class TestDomainApplication(TestCase): (self.withdrawn_application, TransitionNotAllowed), ] - with boto3_mocking.clients.handler_for("sesv2", self.mock_client): - with less_console_noise(): - for application, exception_type in test_cases: - with self.subTest(application=application, exception_type=exception_type): - with self.assertRaises(exception_type): - application.action_needed() + for application, exception_type in test_cases: + with self.subTest(application=application, exception_type=exception_type): + with self.assertRaises(exception_type): + application.action_needed() def test_approved_transition_allowed(self): """ diff --git a/src/registrar/views/application.py b/src/registrar/views/application.py index 84c917604..07db011a2 100644 --- a/src/registrar/views/application.py +++ b/src/registrar/views/application.py @@ -150,6 +150,7 @@ class ApplicationWizard(ApplicationWizardPermissionView, TemplateView): def storage(self): # marking session as modified on every access # so that updates to nested keys are always saved + # push to sandbox will remove self.request.session.modified = True return self.request.session.setdefault(self.prefix, {})