mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-08-01 12:19:47 -04:00
Add remaining endpoints for PDFs and PNGs
Right now we can show what a letter template looks like as a PDF or PNG.
This commit completes the work so this is also possible when:
- showing a template with the placeholders replaced
- showing any version of a template
Also removes dependency on `Exception().message`, which was deprecated
in Python 2.6. See
97f82d565f
for full details.
This commit is contained in:
22
app/utils.py
22
app/utils.py
@@ -12,6 +12,7 @@ from notifications_utils.template import (
|
||||
SMSPreviewTemplate,
|
||||
EmailPreviewTemplate,
|
||||
LetterPDFLinkTemplate,
|
||||
LetterPreviewTemplate,
|
||||
)
|
||||
|
||||
import pyexcel
|
||||
@@ -224,7 +225,13 @@ def is_gov_user(email_address):
|
||||
return bool(re.search(email_regex, email_address.lower()))
|
||||
|
||||
|
||||
def get_template(template, service, show_recipient=False, expand_emails=False):
|
||||
def get_template(
|
||||
template,
|
||||
service,
|
||||
show_recipient=False,
|
||||
expand_emails=False,
|
||||
letter_preview_url=None,
|
||||
):
|
||||
if 'email' == template['template_type']:
|
||||
return EmailPreviewTemplate(
|
||||
template,
|
||||
@@ -241,7 +248,12 @@ def get_template(template, service, show_recipient=False, expand_emails=False):
|
||||
show_recipient=show_recipient
|
||||
)
|
||||
if 'letter' == template['template_type']:
|
||||
return LetterPDFLinkTemplate(
|
||||
template,
|
||||
service_id=service['id'],
|
||||
)
|
||||
if letter_preview_url:
|
||||
return LetterPDFLinkTemplate(
|
||||
template,
|
||||
preview_url=letter_preview_url,
|
||||
)
|
||||
else:
|
||||
return LetterPreviewTemplate(
|
||||
template
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user