From 997fc1bbed611d0776cc3ce3665dc26fee5fa8cd Mon Sep 17 00:00:00 2001 From: zandercymatics <141044360+zandercymatics@users.noreply.github.com> Date: Wed, 2 Oct 2024 09:22:56 -0600 Subject: [PATCH] Remove no longer relevant test + linting --- src/registrar/admin.py | 16 ++++++++++------ src/registrar/models/domain_request.py | 4 ++-- src/registrar/tests/test_models.py | 7 ------- 3 files changed, 12 insertions(+), 15 deletions(-) diff --git a/src/registrar/admin.py b/src/registrar/admin.py index 4410565f7..55b1e5fc4 100644 --- a/src/registrar/admin.py +++ b/src/registrar/admin.py @@ -1942,12 +1942,7 @@ class DomainRequestAdmin(ListHeaderAdmin, ImportExportModelAdmin): # == Handle action needed and rejected emails == # # Edge case: this logic is handled by javascript, so contexts outside that must be handled - if obj.status == DomainRequest.DomainRequestStatus.ACTION_NEEDED: - if obj.action_needed_reason and not obj.action_needed_reason_email: - obj.action_needed_reason_email = get_action_needed_reason_default_email(obj, obj.action_needed_reason) - elif obj.status == DomainRequest.DomainRequestStatus.REJECTED: - if obj.rejection_reason and not obj.rejection_reason_email: - obj.rejection_reason_email = get_rejection_reason_default_email(obj, obj.rejection_reason) + obj = self._handle_custom_emails() # == Handle allowed emails == # if obj.status in DomainRequest.get_statuses_that_send_emails() and not settings.IS_PRODUCTION: @@ -1965,6 +1960,15 @@ class DomainRequestAdmin(ListHeaderAdmin, ImportExportModelAdmin): if should_save: return super().save_model(request, obj, form, change) + def _handle_custom_emails(self, obj): + if obj.status == DomainRequest.DomainRequestStatus.ACTION_NEEDED: + if obj.action_needed_reason and not obj.action_needed_reason_email: + obj.action_needed_reason_email = get_action_needed_reason_default_email(obj, obj.action_needed_reason) + elif obj.status == DomainRequest.DomainRequestStatus.REJECTED: + if obj.rejection_reason and not obj.rejection_reason_email: + obj.rejection_reason_email = get_rejection_reason_default_email(obj, obj.rejection_reason) + return obj + def _check_for_valid_email(self, request, obj): """Certain emails are whitelisted in non-production environments, so we should display that information using this function. diff --git a/src/registrar/models/domain_request.py b/src/registrar/models/domain_request.py index 4877b3756..f43ba80d4 100644 --- a/src/registrar/models/domain_request.py +++ b/src/registrar/models/domain_request.py @@ -709,8 +709,8 @@ class DomainRequest(TimeStampedModel): bcc_address = settings.DEFAULT_FROM_EMAIL if settings.IS_PRODUCTION else "" self._send_status_update_email( new_status=status, - email_template=f"emails/includes/custom_email.txt", - email_template_subject=f"emails/status_change_subject.txt", + email_template="emails/includes/custom_email.txt", + email_template_subject="emails/status_change_subject.txt", bcc_address=bcc_address, custom_email_content=status_info.get("email"), wrap_email=True, diff --git a/src/registrar/tests/test_models.py b/src/registrar/tests/test_models.py index 0b01ee0a6..ba52ba21d 100644 --- a/src/registrar/tests/test_models.py +++ b/src/registrar/tests/test_models.py @@ -355,13 +355,6 @@ class TestDomainRequest(TestCase): domain_request, msg, "withdraw", 1, expected_content="withdrawn", expected_email=user.email ) - @less_console_noise_decorator - def test_reject_sends_email(self): - msg = "Create a domain request and reject it and see if email was sent." - user, _ = User.objects.get_or_create(username="testy") - domain_request = completed_domain_request(status=DomainRequest.DomainRequestStatus.APPROVED, user=user) - self.check_email_sent(domain_request, msg, "reject", 1, expected_content="Hi", expected_email=user.email) - @less_console_noise_decorator def test_reject_with_prejudice_does_not_send_email(self): msg = "Create a domain request and reject it with prejudice and see if email was sent."