Merge pull request #2088 from alphagov/branding-request

Add page where users can say they want branding
This commit is contained in:
Chris Hill-Scott
2018-05-18 16:35:10 +01:00
committed by GitHub
12 changed files with 230 additions and 21 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.9 KiB

View File

@@ -241,3 +241,13 @@ details .arrow {
}
}
.bordered-image {
padding: 5px;
outline: 1px solid $border-colour;
max-width: 100%;
label & {
cursor: pointer;
}
}

View File

@@ -931,3 +931,23 @@ class LinkOrganisationsForm(StripWhitespaceForm):
DataRequired()
]
)
branding_options = (
('govuk', 'GOV.UK only'),
('both', 'GOV.UK and logo'),
('org', 'Your logo'),
('org_banner', 'Your logo on a colour'),
)
branding_options_dict = dict(branding_options)
class BrandingOptionsEmail(StripWhitespaceForm):
options = RadioField(
'Branding options',
choices=branding_options,
validators=[
DataRequired()
],
)

View File

@@ -25,6 +25,7 @@ from app import (
)
from app.main import main
from app.main.forms import (
BrandingOptionsEmail,
ConfirmPasswordForm,
FreeSMSAllowance,
InternationalSMSForm,
@@ -41,6 +42,7 @@ from app.main.forms import (
ServiceSmsSenderForm,
ServiceSwitchLettersForm,
SMSPrefixForm,
branding_options_dict,
)
from app.utils import (
AgreementInfo,
@@ -884,6 +886,44 @@ def link_service_to_organisation(service_id):
)
@main.route("/services/<service_id>/branding-request/email", methods=['GET', 'POST'])
@login_required
@user_has_permissions('manage_service')
def branding_request(service_id):
form = BrandingOptionsEmail(
options=current_service['branding']
)
if form.validate_on_submit():
zendesk_client.create_ticket(
subject='Email branding request - {}'.format(current_service['name']),
message=(
'On behalf of {} ({})\n'
'\n---'
'\nBranding requested: {}'
).format(
current_service['name'],
url_for('main.service_dashboard', service_id=current_service['id'], _external=True),
branding_options_dict[form.options.data],
),
ticket_type=zendesk_client.TYPE_QUESTION,
user_email=current_user.email_address,
user_name=current_user.name,
)
flash((
'Thanks for your branding request. Well get back to you '
'within one working day.'
), 'default')
return redirect(url_for('.service_settings', service_id=service_id))
return render_template(
'views/service-settings/branding/email-options.html',
form=form,
)
def get_branding_as_value_and_label(email_branding):
return [
(branding['id'], branding['name'])

View File

@@ -109,6 +109,7 @@ class HeaderNavigation(Navigation):
'api_integration',
'api_keys',
'archive_service',
'branding_request',
'callbacks',
'cancel_invited_org_user',
'cancel_invited_user',
@@ -309,6 +310,7 @@ class MainNavigation(Navigation):
'usage',
},
'settings': {
'branding_request',
'link_service_to_organisation',
'request_to_go_live',
'service_add_email_reply_to',
@@ -519,6 +521,7 @@ class OrgNavigation(Navigation):
'api_keys',
'archive_service',
'bat_phone',
'branding_request',
'callbacks',
'cancel_invited_org_user',
'cancel_invited_user',

View File

@@ -18,31 +18,36 @@
{% endif %}
</legend>
{% for option in field %}
<div class="multiple-choice">
<input
id="{{ option.id }}" name="{{ option.name }}" type="radio" value="{{ option.data }}"
{% if option.data in disable %}
disabled
{% endif %}
{% if option.checked %}
checked
{% endif %}
>
<label class="block-label" for="{{ option.id }}">
{{ option.label.text }}
{% if option_hints[option.data] %}
<div class="block-label-hint">
{{ option_hints[option.data] }}
</div>
{% endif %}
</label>
</div>
{{ radio(option, disable, option_hints) }}
{% endfor %}
</fieldset>
</div>
{% endmacro %}
{% macro radio(option, disable=[], option_hints={}) %}
<div class="multiple-choice">
<input
id="{{ option.id }}" name="{{ option.name }}" type="radio" value="{{ option.data }}"
{% if option.data in disable %}
disabled
{% endif %}
{% if option.checked %}
checked
{% endif %}
>
<label class="block-label" for="{{ option.id }}">
{{ option.label.text }}
{% if option_hints[option.data] %}
<div class="block-label-hint">
{{ option_hints[option.data] }}
</div>
{% endif %}
</label>
</div>
{% endmacro %}
{% macro radio_select(
field,
hint=None,

View File

@@ -89,6 +89,17 @@
}}
{% endcall %}
{% call row() %}
{{ text_field('Email branding') }}
{{ text_field(
'GOV.UK' if current_service.branding == 'govuk' else 'Your branding'
) }}
{{ edit_field(
'Change',
url_for('.branding_request', service_id=current_service.id),
)}}
{% endcall %}
{% endif %}
{% endcall %}

View File

@@ -0,0 +1,46 @@
{% extends "withnav_template.html" %}
{% from "components/radios.html" import radio %}
{% from "components/textbox.html" import textbox %}
{% from "components/page-footer.html" import page_footer %}
{% block service_page_title %}
Email branding
{% endblock %}
{% block maincolumn_content %}
<h1 class="heading-large">Email branding</h1>
<form method="post">
<fieldset class="form-group {% if form.options.errors %}form-group-error{% endif %} top-gutter">
<legend class="bottom-gutter-2-3">
Choose the branding youd like on your emails.
</legend>
{% if form.options.errors %}
<span class="error-message" data-module="track-error" data-error-type="Cant be empty" data-error-label="{{ form.options.name }}">
You need to choose an option
</span>
{% endif %}
<div class="grid-row">
{% for option in form.options %}
<div class="column-one-quarter">
<label for="{{ option.id }}">
<img src="/static/images/branding-options/{{ option.data }}.png" alt="" class="bordered-image bottom-gutter-1-3">
</label>
{{ radio(option) }}
</div>
{% endfor %}
</div>
</fieldset>
<p class="form-group">
Well email you once your brandings ready to use, or if we need any
more info.
</p>
{{ page_footer(
'Request new branding',
destructive=destructive,
back_link=url_for('.service_settings', service_id=current_service.id)
) }}
</form>
{% endblock %}

View File

@@ -54,6 +54,7 @@ def mock_get_service_settings_page_common(
'Label Value Action',
'Send emails On Change',
'Email reply to addresses Not set Change',
'Email branding GOV.UK Change',
'Label Value Action',
'Send text messages On Change',
@@ -75,6 +76,7 @@ def mock_get_service_settings_page_common(
'Label Value Action',
'Send emails On Change',
'Email reply to addresses Not set Change',
'Email branding GOV.UK Change',
'Label Value Action',
'Send text messages On Change',
@@ -134,6 +136,7 @@ def test_should_show_overview(
'Label Value Action',
'Send emails On Change',
'Email reply to addresses test@example.com Manage',
'Email branding GOV.UK Change',
'Label Value Action',
'Send text messages On Change',
@@ -154,6 +157,7 @@ def test_should_show_overview(
'Label Value Action',
'Send emails On Change',
'Email reply to addresses test@example.com Manage',
'Email branding GOV.UK Change',
'Label Value Action',
'Send text messages On Change',
@@ -775,8 +779,8 @@ def test_and_more_hint_appears_on_settings_with_more_than_just_a_single_sender(
)
assert get_row(page, 3) == "Email reply to addresses test@example.com …and 2 more Manage"
assert get_row(page, 5) == "Text message sender Example …and 2 more Manage"
assert get_row(page, 10) == "Sender addresses 1 Example Street …and 2 more Manage"
assert get_row(page, 6) == "Text message sender Example …and 2 more Manage"
assert get_row(page, 11) == "Sender addresses 1 Example Street …and 2 more Manage"
@pytest.mark.parametrize('sender_list_page, expected_output', [
@@ -2385,3 +2389,73 @@ def test_update_service_organisation_does_not_update_if_same_value(
assert response.status_code == 302
mock_update_service_organisation.called is False
def test_show_email_branding_request_page(
client_request,
):
page = client_request.get(
'.branding_request', service_id=SERVICE_ONE_ID
)
radios = page.select('input[type=radio]')
for index, option in enumerate((
'govuk',
'both',
'org',
'org_banner',
)):
assert radios[index]['name'] == 'options'
assert radios[index]['value'] == option
@pytest.mark.parametrize('choice, requested_branding', (
('govuk', 'GOV.UK only'),
('both', 'GOV.UK and logo'),
('org', 'Your logo'),
('org_banner', 'Your logo on a colour'),
pytest.mark.xfail(('foo', 'Nope'), raises=AssertionError),
))
def test_submit_email_branding_request(
client_request,
mocker,
choice,
requested_branding,
mock_get_service_settings_page_common,
no_reply_to_email_addresses,
no_letter_contact_blocks,
mock_get_service_organisation,
single_sms_sender,
):
zendesk = mocker.patch(
'app.main.views.service_settings.zendesk_client.create_ticket',
autospec=True,
)
page = client_request.post(
'.branding_request', service_id=SERVICE_ONE_ID,
_data={
'options': choice,
},
_follow_redirects=True,
)
zendesk.assert_called_once_with(
message=(
'On behalf of service one '
'(http://localhost/services/596364a0-858e-42c8-9062-a8fe822260eb)\n'
'\n'
'---\n'
'Branding requested: {}'
).format(requested_branding),
subject='Email branding request - service one',
ticket_type='question',
user_email='test@user.gov.uk',
user_name='Test User',
)
assert normalize_spaces(page.select_one('.banner-default').text) == (
'Thanks for your branding request. Well get back to you '
'within one working day.'
)