This commit is contained in:
zandercymatics 2024-06-12 08:14:27 -06:00
parent 1e720b7398
commit 6113176d55
No known key found for this signature in database
GPG key ID: FF4636ABEC9682B7
2 changed files with 12 additions and 5 deletions

View file

@ -805,6 +805,10 @@ class DomainRequest(TimeStampedModel):
email_template_name = f"{self.action_needed_reason}.txt"
email_template_subject_name = f"{self.action_needed_reason}_subject.txt"
bcc_address = ""
if settings.IS_PRODUCTION:
bcc_address = settings.DEFAULT_FROM_EMAIL
# If we can, try to send out an email as long as send_email=True
if can_send_email:
self._send_status_update_email(
@ -812,7 +816,7 @@ class DomainRequest(TimeStampedModel):
email_template=f"emails/action_needed_reasons/{email_template_name}",
email_template_subject=f"emails/action_needed_reasons/{email_template_subject_name}",
send_email=send_email,
bcc_address="help@get.gov",
bcc_address=bcc_address,
wrap_email=True,
)

View file

@ -1500,6 +1500,9 @@ class TestDomainRequestAdmin(MockEppLib):
def test_action_needed_sends_reason_email(self):
"""When an action needed reason is set, an email is sent out."""
# TODO CHANGE BEFORE MERGING
settings.DEFAULT_FROM_EMAIL
BCC_EMAIL = "fake"
# Ensure there is no user with this email
EMAIL = "mayor@igorville.gov"
User.objects.filter(email=EMAIL).delete()
@ -1512,25 +1515,25 @@ class TestDomainRequestAdmin(MockEppLib):
# Test the email sent out for already_has_domains
already_has_domains = DomainRequest.ActionNeededReasons.ALREADY_HAS_DOMAINS
self.transition_state_and_send_email(domain_request, action_needed, action_needed_reason=already_has_domains)
self.assert_email_is_accurate("ORGANIZATION ALREADY HAS A .GOV DOMAIN", 0, EMAIL, True)
self.assert_email_is_accurate("ORGANIZATION ALREADY HAS A .GOV DOMAIN", 0, EMAIL, bcc_email_address="help@get.gov")
self.assertEqual(len(self.mock_client.EMAILS_SENT), 1)
# Test the email sent out for bad_name
bad_name = DomainRequest.ActionNeededReasons.BAD_NAME
self.transition_state_and_send_email(domain_request, action_needed, action_needed_reason=bad_name)
self.assert_email_is_accurate("DOMAIN NAME DOES NOT MEET .GOV REQUIREMENTS", 1, EMAIL, True)
self.assert_email_is_accurate("DOMAIN NAME DOES NOT MEET .GOV REQUIREMENTS", 1, EMAIL, bcc_email_address="help@get.gov")
self.assertEqual(len(self.mock_client.EMAILS_SENT), 2)
# Test the email sent out for eligibility_unclear
eligibility_unclear = DomainRequest.ActionNeededReasons.ELIGIBILITY_UNCLEAR
self.transition_state_and_send_email(domain_request, action_needed, action_needed_reason=eligibility_unclear)
self.assert_email_is_accurate("ORGANIZATION MAY NOT MEET ELIGIBILITY REQUIREMENTS", 2, EMAIL, True)
self.assert_email_is_accurate("ORGANIZATION MAY NOT MEET ELIGIBILITY REQUIREMENTS", 2, EMAIL, bcc_email_address="help@get.gov")
self.assertEqual(len(self.mock_client.EMAILS_SENT), 3)
# Test the email sent out for questionable_ao
questionable_ao = DomainRequest.ActionNeededReasons.QUESTIONABLE_AUTHORIZING_OFFICIAL
self.transition_state_and_send_email(domain_request, action_needed, action_needed_reason=questionable_ao)
self.assert_email_is_accurate("AUTHORIZING OFFICIAL DOES NOT MEET ELIGIBILITY REQUIREMENTS", 3, EMAIL, True)
self.assert_email_is_accurate("AUTHORIZING OFFICIAL DOES NOT MEET ELIGIBILITY REQUIREMENTS", 3, EMAIL, bcc_email_address="help@get.gov")
self.assertEqual(len(self.mock_client.EMAILS_SENT), 4)
# Assert that no other emails are sent on OTHER