Strip newline

This commit is contained in:
zandercymatics 2024-06-20 12:29:12 -06:00
parent 32463dd7a7
commit 4c84ad8456
No known key found for this signature in database
GPG key ID: FF4636ABEC9682B7
4 changed files with 13 additions and 18 deletions

View file

@ -791,6 +791,7 @@ div.dja__model-description{
textarea { textarea {
width: 100%; width: 100%;
resize: none; resize: none;
cursor: pointer;
&::-webkit-scrollbar { &::-webkit-scrollbar {
background-color: transparent; background-color: transparent;
@ -805,18 +806,6 @@ div.dja__model-description{
border: 3px solid transparent; border: 3px solid transparent;
} }
&::-webkit-scrollbar-thumb:hover {
cursor: pointer;
}
&::-webkit-scrollbar-button {
display: none;
}
::-webkit-scrollbar-corner {
display: none;
}
} }

View file

@ -577,12 +577,9 @@ class DomainRequest(TimeStampedModel):
# Return the content of the rendered views # Return the content of the rendered views
context = {"domain_request": self} context = {"domain_request": self}
# autoescape off adds a newline to the beginning of the email.
# This is fine when the email is rendered, but we don't need this for display.
email_body_text = template.render(context=context).lstrip().lstrip("\n")
return { return {
"subject_text": subject_template.render(context=context), "subject_text": subject_template.render(context=context),
"email_body_text": email_body_text "email_body_text": template.render(context=context)
} }

View file

@ -109,10 +109,10 @@ This is using a custom implementation fieldset.html (see admin/fieldset.html)
{% if original_object.action_needed_reason_email %} {% if original_object.action_needed_reason_email %}
<div class="dja-readonly-textarea-container padding-1 margin-top-2 thin-border display-none"> <div class="dja-readonly-textarea-container padding-1 margin-top-2 thin-border display-none">
<label class="max-full" for="action_needed_reason_email_view_more"> <label class="max-full" for="action_needed_reason_email_view_more">
<strong>Auto-generated email (will be sent to submitter)</strong> <strong>Auto-generated email (sent to submitter)</strong>
</label> </label>
<textarea id="action_needed_reason_email_view_more" cols="40" rows="20" class="no-border" readonly> <textarea id="action_needed_reason_email_view_more" cols="40" rows="20" class="no-border" readonly>
{{ original_object.action_needed_reason_email }} {{ original_object.action_needed_reason_email|strip_beginning_newline_and_spaces }}
</textarea> </textarea>
</div> </div>
{% endif %} {% endif %}

View file

@ -145,3 +145,12 @@ def format_phone(value):
phone_number = PhoneNumber.from_string(value) phone_number = PhoneNumber.from_string(value)
return phone_number.as_national return phone_number.as_national
return value return value
@register.filter
def strip_beginning_newline_and_spaces(value):
"""Removes any newline characters (and spaces)
on the first line of a given string"""
if value and isinstance(value, str):
return value.lstrip("\n").lstrip(" ")
else:
return value