mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-08-19 05:59:44 -04:00
Merge pull request #1237 from alphagov/multi-page-previews
Show all pages of a letter in the app
This commit is contained in:
@@ -6,7 +6,7 @@ from app import current_service
|
||||
|
||||
class TemplatePreview:
|
||||
@classmethod
|
||||
def from_database_object(cls, template, filetype, values=None):
|
||||
def from_database_object(cls, template, filetype, values=None, page=None):
|
||||
data = {
|
||||
'letter_contact_block': current_service['letter_contact_block'],
|
||||
'template': template,
|
||||
@@ -14,16 +14,21 @@ class TemplatePreview:
|
||||
'dvla_org_id': current_service['dvla_organisation'],
|
||||
}
|
||||
resp = requests.post(
|
||||
'{}/preview.{}'.format(current_app.config['TEMPLATE_PREVIEW_API_HOST'], filetype),
|
||||
'{}/preview.{}{}'.format(
|
||||
current_app.config['TEMPLATE_PREVIEW_API_HOST'],
|
||||
filetype,
|
||||
'?page={}'.format(page) if page else '',
|
||||
),
|
||||
json=data,
|
||||
headers={'Authorization': 'Token {}'.format(current_app.config['TEMPLATE_PREVIEW_API_KEY'])}
|
||||
)
|
||||
return (resp.content, resp.status_code, resp.headers.items())
|
||||
|
||||
@classmethod
|
||||
def from_utils_template(cls, template, filetype):
|
||||
def from_utils_template(cls, template, filetype, page=None):
|
||||
return cls.from_database_object(
|
||||
template._template,
|
||||
filetype,
|
||||
template.values
|
||||
template.values,
|
||||
page=page,
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user