Show letter branding preview when selecting a brand

This adds a preview pane which is visible when updating a letter brand.

If JavaScript is enabled, the preview pane shows on the set-letter-branding
page, and submitting the form saves updates the letter brand for a service
immediately. If Javascript is not enabled, there is a separate 'Preview email
branding' page which shows a preview of the brand and has a 'Save' button on it.
This commit is contained in:
Katie Smith
2019-02-15 14:47:39 +00:00
parent 44781e3b69
commit d904c7e5c5
12 changed files with 297 additions and 11 deletions

View File

@@ -102,3 +102,20 @@ def test_page_count_unpacks_from_json_response(
assert partial_call({'template_type': 'letter'}) == 99
mock_template_preview.assert_called_once_with(*expected_template_preview_args)
def test_from_example_template_makes_request(mocker):
request_mock = mocker.patch('app.template_previews.requests.post')
template = {}
filename = 'geo'
TemplatePreview.from_example_template(template, filename)
request_mock.assert_called_once_with(
'http://localhost:9999/preview.png',
headers={'Authorization': 'Token my-secret-key'},
json={'values': None,
'template': template,
'filename': filename,
'letter_contact_block': None}
)