From 77aba35c4922668e84cb61fe47d90e8b9f278e56 Mon Sep 17 00:00:00 2001
From: Chris Hill-Scott
Date: Wed, 23 Jan 2019 10:16:43 +0000
Subject: [PATCH] =?UTF-8?q?Add=20an=20=E2=80=98add=20logo=E2=80=99=20butto?=
=?UTF-8?q?n?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Because some people don’t know they can put their own logo on letters:
> The HM Government Logo is at the top of the letter and we can't see
> a way of putting the [organisation] logo on
> We are intending to use the letter template feature for the first time
> and wondered whether the branding is configurable or whether the HM
> Government header is the standard default.
> Can we replace HM Government logo with our own in the letter? IF yes,
> then how?
> I don't seem to be able to set the branding on the letters to be
> [organisation]. it's always HM government. Is there something that
> needs enabling for this account?
No-one actually wants the HM Government logo (no-one is sending real
letters using it). So we should leave the space blank and put a button
there prompting people to add their own logo.
---
app/assets/stylesheets/views/template.scss | 6 +++++
app/main/views/service_settings.py | 1 +
.../request-letter-branding.html | 15 ++++++++----
app/templates/views/templates/_template.html | 1 +
tests/app/main/views/test_service_settings.py | 24 +++++++++++++++----
5 files changed, 39 insertions(+), 8 deletions(-)
diff --git a/app/assets/stylesheets/views/template.scss b/app/assets/stylesheets/views/template.scss
index 6ac49aa85..df7539f5b 100644
--- a/app/assets/stylesheets/views/template.scss
+++ b/app/assets/stylesheets/views/template.scss
@@ -45,3 +45,9 @@
top: 51px; // aligns bottom edge to bottom of postmark
right: 145px; // Aligns right edge to midpoint of postmark and fold
}
+
+.edit-template-link-letter-branding {
+ @extend %edit-template-link;
+ top: 51px; // aligns with ‘change postage’ link
+ left: 66px; // Aligns to left of logo area
+}
diff --git a/app/main/views/service_settings.py b/app/main/views/service_settings.py
index 6d3b51de3..69b477de2 100644
--- a/app/main/views/service_settings.py
+++ b/app/main/views/service_settings.py
@@ -829,6 +829,7 @@ def service_set_letter_branding(service_id):
def request_letter_branding(service_id):
return render_template(
'views/service-settings/request-letter-branding.html',
+ from_template=request.args.get('from_template'),
)
diff --git a/app/templates/views/service-settings/request-letter-branding.html b/app/templates/views/service-settings/request-letter-branding.html
index 85c645fe9..5095c298c 100644
--- a/app/templates/views/service-settings/request-letter-branding.html
+++ b/app/templates/views/service-settings/request-letter-branding.html
@@ -22,10 +22,17 @@
Contact support
if you want to use a different logo.
- {{ page_footer(
- back_link=url_for('.service_settings', service_id=current_service.id),
- back_link_text='Back to settings'
- ) }}
+ {% if from_template %}
+ {{ page_footer(
+ back_link=url_for('.view_template', service_id=current_service.id, template_id=from_template),
+ back_link_text='Back to template'
+ ) }}
+ {% else %}
+ {{ page_footer(
+ back_link=url_for('.service_settings', service_id=current_service.id),
+ back_link_text='Back to settings'
+ ) }}
+ {% endif %}
diff --git a/app/templates/views/templates/_template.html b/app/templates/views/templates/_template.html
index 5eb968b3e..1816ee7d7 100644
--- a/app/templates/views/templates/_template.html
+++ b/app/templates/views/templates/_template.html
@@ -44,6 +44,7 @@
{% if current_user.has_permissions('manage_templates') and template.template_type == 'letter' %}
+
Add logo
Change
Edit
Edit
diff --git a/tests/app/main/views/test_service_settings.py b/tests/app/main/views/test_service_settings.py
index f0594b481..59477c3cd 100644
--- a/tests/app/main/views/test_service_settings.py
+++ b/tests/app/main/views/test_service_settings.py
@@ -34,6 +34,8 @@ from tests.conftest import (
platform_admin_user,
)
+FAKE_TEMPLATE_ID = uuid4()
+
@pytest.fixture
def mock_get_service_settings_page_common(
@@ -2032,12 +2034,12 @@ def test_set_letter_contact_block_redirects_to_template(
mock_update_service,
):
service_one['permissions'] = ['letter']
- fake_template_id = uuid4()
+
response = logged_in_client.post(
url_for(
'main.service_set_letter_contact_block',
service_id=service_one['id'],
- from_template=fake_template_id,
+ from_template=FAKE_TEMPLATE_ID,
),
data={'letter_contact_block': '23 Whitechapel Road'},
)
@@ -2045,7 +2047,7 @@ def test_set_letter_contact_block_redirects_to_template(
assert response.location == url_for(
'main.view_template',
service_id=service_one['id'],
- template_id=fake_template_id,
+ template_id=FAKE_TEMPLATE_ID,
_external=True,
)
@@ -2066,14 +2068,26 @@ def test_set_letter_contact_block_has_max_10_lines(
assert error_message == 'Contains 11 lines, maximum is 10'
+@pytest.mark.parametrize('extra_args, expected_partial_url', (
+ (
+ {},
+ partial(url_for, 'main.service_settings')
+ ),
+ (
+ {'from_template': FAKE_TEMPLATE_ID},
+ partial(url_for, 'main.view_template', template_id=FAKE_TEMPLATE_ID)
+ ),
+))
def test_request_letter_branding(
client_request,
mock_get_letter_branding_by_id,
- service_one
+ extra_args,
+ expected_partial_url,
):
request_page = client_request.get(
'main.request_letter_branding',
service_id=SERVICE_ONE_ID,
+ **extra_args
)
assert request_page.select_one('main p').text.strip() == 'Your letters have no logo.'
link_href = request_page.select_one('main a')['href']
@@ -2081,6 +2095,8 @@ def test_request_letter_branding(
assert feedback_page.select_one('textarea').text.strip() == (
'I would like my own logo on my letter templates.'
)
+ back_link_href = request_page.select('main a')[1]['href']
+ assert back_link_href == expected_partial_url(service_id=SERVICE_ONE_ID)
def test_request_letter_branding_if_already_have_branding(