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:
Chris Hill-Scott
2019-02-07 11:40:02 +00:00
parent a0e33f0d75
commit f185dbecbe
3 changed files with 61 additions and 8 deletions

View File

@@ -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,