Show all pages of a letter in the app

In research we’ve seen two problems with the click-to-see-PDF thing:

- it’s not very intuitive that the letter is clickable, or what you
  can expect when clicking the letter
- people get lost of stuck in the PDF view because it opens in the same
  tab, or they open it in a new tab and then get find their way back, or
  …

So this commit changes the show template page to show the entire
contents of the letter, same as we do for emails and text messages.

Right now it only does it on the view template page. I think we’ll have
to work out a way of showing some kind of truncated version on the _Send
yourself a test_ and _Preview_ pages. But that’s for later.
This commit is contained in:
Chris Hill-Scott
2017-04-20 10:40:15 +01:00
parent 38fbc3c47d
commit 36db0ad598
5 changed files with 60 additions and 16 deletions

View File

@@ -6,23 +6,28 @@ 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,
'values': values
}
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,
)