Logic refactor

This commit is contained in:
zandercymatics 2024-07-08 14:13:29 -06:00
parent f18b10d669
commit 425cfbcb4e
No known key found for this signature in database
GPG key ID: FF4636ABEC9682B7
4 changed files with 48 additions and 45 deletions

View file

@ -874,14 +874,10 @@ class DomainRequest(TimeStampedModel):
def _send_action_needed_reason_email(self, send_email=True, email_content=None):
"""Sends out an automatic email for each valid action needed reason provided"""
# Store the filenames of the template and template subject
email_template_name: str = ""
email_template_subject_name: str = ""
# Check if the current email that we sent out is the same as our defaults.
# If these differ, then that means that we're sending custom content.
default_email = self.get_default_action_needed_reason_email(self.action_needed_reason)
if self.action_needed_reason_email and self.action_needed_reason_email != default_email:
if email_content is not None:
email_template_name = "custom_email.txt"
# Check for the "type" of action needed reason.
@ -916,21 +912,6 @@ class DomainRequest(TimeStampedModel):
wrap_email=True,
)
def get_default_action_needed_reason_email(self, action_needed_reason):
"""Returns the default email associated with the given action needed reason"""
if action_needed_reason is None or action_needed_reason == self.ActionNeededReasons.OTHER:
return None
# Get the email body
template_path = f"emails/action_needed_reasons/{action_needed_reason}.txt"
template = get_template(template_path)
recipient = self.creator if flag_is_active(None, "profile_feature") else self.submitter
# Return the content of the rendered views
context = {"domain_request": self, "recipient": recipient}
body_text = template.render(context=context).strip().lstrip("\n")
return body_text
@transition(
field="status",
source=[