mirror of
https://github.com/GSA/notifications-api.git
synced 2025-12-12 16:22:17 -05:00
Return rendered HTML when previewing a template
If you’re trying to show what a Notify email will look like in your caseworking system all the API gives you at the moment is raw markdown (with the placeholders replaced). This isn’t that useful if your caseworkers have no idea what markdown is. If we also give teams the HTML then they can embed this in their systems, and the people using those systems will be able to see how headings, bulleted lists, etc. look.
This commit is contained in:
14
app/utils.py
14
app/utils.py
@@ -3,7 +3,7 @@ from datetime import datetime, timedelta
|
||||
import pytz
|
||||
from flask import url_for
|
||||
from sqlalchemy import func
|
||||
from notifications_utils.template import SMSMessageTemplate, WithSubjectTemplate
|
||||
from notifications_utils.template import SMSMessageTemplate, WithSubjectTemplate, get_html_email_body
|
||||
from notifications_utils.timezones import convert_utc_to_bst
|
||||
|
||||
local_timezone = pytz.timezone("Europe/London")
|
||||
@@ -35,6 +35,18 @@ def get_template_instance(template, values):
|
||||
}[template['template_type']](template, values)
|
||||
|
||||
|
||||
def get_html_email_body_from_template(template_instance):
|
||||
from app.models import EMAIL_TYPE
|
||||
|
||||
if template_instance.template_type != EMAIL_TYPE:
|
||||
return None
|
||||
|
||||
return get_html_email_body(
|
||||
template_instance.content,
|
||||
template_instance.values,
|
||||
)
|
||||
|
||||
|
||||
def get_london_midnight_in_utc(date):
|
||||
"""
|
||||
This function converts date to midnight as BST (British Standard Time) to UTC,
|
||||
|
||||
Reference in New Issue
Block a user