mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-08-24 16:24:08 -04:00
remove pdf/png code from admin app entirely
while PDFs work on paas, they only do that because it turns out the python buildpack happens to have imagemagick preinstalled - if that ever changes then it'd break. so move those to the template preview service. This also means we can get rid of weazyprint and wand dependencies
This commit is contained in:
@@ -1,17 +1,29 @@
|
||||
from flask import current_app, current_service
|
||||
from flask import current_app
|
||||
import requests
|
||||
|
||||
from app import current_service
|
||||
|
||||
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())
|
||||
|
||||
class TemplatePreview:
|
||||
@classmethod
|
||||
def from_database_object(cls, template, filetype, values=None):
|
||||
data = {
|
||||
"letter_contact_block": current_service['letter_contact_block'],
|
||||
"admin_base_url": current_app.config['ADMIN_BASE_URL'],
|
||||
"template": template,
|
||||
"values": values
|
||||
}
|
||||
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())
|
||||
|
||||
@classmethod
|
||||
def from_utils_template(cls, template, filetype):
|
||||
return cls.from_database_object(
|
||||
template._template,
|
||||
filetype,
|
||||
template.values
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user