Generate letter previews in the new notifications-template-preview service

by calling through to this, we no longer require admin app to ship
with binary dependencies (imagemagick/cairo/etc)
This commit is contained in:
Leo Hemsted
2017-04-10 15:10:34 +01:00
parent 27d2e3a738
commit 64d162d96e
3 changed files with 41 additions and 10 deletions

17
app/template_previews.py Normal file
View File

@@ -0,0 +1,17 @@
from flask import current_app, current_service
import requests
def get_template_preview(template, filetype):
data = {
"letter_contact_block": current_service['letter_contact_block'],
"admin_base_url": current_app.config['ADMIN_BASE_URL'],
"template": template,
"values": None
}
resp = requests.post(
'{}/preview.{}'.format(current_app.config['TEMPLATE_PREVIEW_SERVICE_URL'], filetype),
json=data,
headers={'Authorization': 'Token my-secret-key'}
)
return (resp.content, resp.status_code, resp.headers.items())