custom content logic

This commit is contained in:
zandercymatics 2024-07-01 09:56:09 -06:00
parent 1cbd9234be
commit b6a70e6d3c
No known key found for this signature in database
GPG key ID: FF4636ABEC9682B7
3 changed files with 15 additions and 7 deletions

View file

@ -1948,7 +1948,11 @@ class DomainRequestAdmin(ListHeaderAdmin, ImportExportModelAdmin):
} }
# Get the email body # Get the email body
template_path = f"emails/action_needed_reasons/{action_needed_reason}.txt" if not custom_text:
template_path = f"emails/action_needed_reasons/{action_needed_reason}.txt"
else:
template_path = f"emails/action_needed_reasons/custom_email.txt"
template = get_template(template_path) template = get_template(template_path)
# Get the email subject # Get the email subject

View file

@ -618,7 +618,8 @@ class DomainRequest(TimeStampedModel):
if was_already_action_needed and (reason_exists and reason_changed): if was_already_action_needed and (reason_exists and reason_changed):
# We don't send emails out in state "other" # We don't send emails out in state "other"
if self.action_needed_reason != self.ActionNeededReasons.OTHER: if self.action_needed_reason != self.ActionNeededReasons.OTHER:
self._send_action_needed_reason_email() _email_content = self.action_needed_reason_email
self._send_action_needed_reason_email(custom_email_content=_email_content)
def sync_yes_no_form_fields(self): def sync_yes_no_form_fields(self):
"""Some yes/no forms use a db field to track whether it was checked or not. """Some yes/no forms use a db field to track whether it was checked or not.
@ -863,8 +864,8 @@ class DomainRequest(TimeStampedModel):
"""Sends out an automatic email for each valid action needed reason provided""" """Sends out an automatic email for each valid action needed reason provided"""
# Store the filenames of the template and template subject # Store the filenames of the template and template subject
email_template_name: str = "" email_template_name: str = "" if not custom_email_content else "custom_email.txt"
email_template_subject_name: str = "" if not custom_email_content else "custom_email" email_template_subject_name: str = ""
# Check for the "type" of action needed reason. # Check for the "type" of action needed reason.
can_send_email = True can_send_email = True
@ -876,8 +877,10 @@ class DomainRequest(TimeStampedModel):
# Assumes that the template name matches the action needed reason if nothing is specified. # Assumes that the template name matches the action needed reason if nothing is specified.
# This is so you can override if you need, or have this taken care of for you. # This is so you can override if you need, or have this taken care of for you.
if not email_template_name and not email_template_subject_name: if not email_template_name:
email_template_name = f"{self.action_needed_reason}.txt" email_template_name = f"{self.action_needed_reason}.txt"
if not email_template_subject_name:
email_template_subject_name = f"{self.action_needed_reason}_subject.txt" email_template_subject_name = f"{self.action_needed_reason}_subject.txt"
bcc_address = "" bcc_address = ""

View file

@ -1,2 +1,3 @@
{% comment %} {% autoescape off %}{# In a text file, we don't want to have HTML entities escaped #} {% endcomment %} {% autoescape off %}{# In a text file, we don't want to have HTML entities escaped #}
{{ custom_email_content }} {{ custom_email_content }}
{% endautoescape %}