Merge pull request #3632 from alphagov/training-broadcast-approved

Add a tour screen once a broadcast is approved
This commit is contained in:
Chris Hill-Scott
2020-09-23 11:07:03 +01:00
committed by GitHub
3 changed files with 88 additions and 12 deletions

View File

@@ -23,7 +23,7 @@ from app.utils import service_has_permission, user_has_permissions
@user_has_permissions()
@service_has_permission('broadcast')
def broadcast_tour(service_id, step_index):
if step_index not in (1, 2, 3, 4, 5):
if step_index not in (1, 2, 3, 4, 5, 6):
abort(404)
return render_template(
f'views/broadcast/tour/{step_index}.html'
@@ -298,6 +298,13 @@ def approve_broadcast_message(service_id, broadcast_message_id):
broadcast_message.approve_broadcast()
if current_service.trial_mode:
return redirect(url_for(
'.broadcast_tour',
service_id=current_service.id,
step_index=6,
))
return redirect(url_for(
'.view_broadcast_message',
service_id=current_service.id,

View File

@@ -0,0 +1,41 @@
{% from "components/banner.html" import banner_wrapper %}
{% extends "admin_template.html" %}
{% block per_page_title %}
Notify has not broadcast your alert because youre still in training mode.
{% endblock %}
{% set mainClasses = "govuk-!-padding-top-0 govuk-!-padding-bottom-0" %}
{% block content %}
<div class="navigation-service">
<div class="navigation-service-name govuk-!-font-weight-bold">
{{ current_service.name }} <span class="navigation-service-type--training">Training</span>
</div>
</div>
<div class="banner-tour banner-tour-no-fixed-height banner-tour-with-service-name">
<div class="govuk-grid-row">
<div class="govuk-grid-column-one-half">
<h1 class="heading-medium">
Notify has not broadcast your alert because youre still in training mode.
</h1>
<p class="govuk-body heading-medium">
In a real emergency, every mobile phone in the area
you chose would make a loud alarm noise.
</p>
<p class="govuk-body heading-medium">
<a class="govuk-link govuk-link--no-visited-state" href='{{ url_for(".service_dashboard", service_id=current_service.id) }}'>
Continue to dashboard
</a>
</p>
</div>
<div class="govuk-grid-column-one-half">
<img src="{{ asset_url('images/broadcast-tour/3.png') }}" alt="">
</div>
</div>
</div>
{% endblock %}

View File

@@ -140,6 +140,7 @@ def test_broadcast_pages_403_for_user_without_permission(
(3, 'Continue', partial(url_for, '.broadcast_tour', step_index=4)),
(4, 'Continue', partial(url_for, '.broadcast_tour', step_index=5)),
(5, 'Continue to dashboard', partial(url_for, '.service_dashboard')),
(6, 'Continue to dashboard', partial(url_for, '.service_dashboard')),
))
def test_broadcast_tour_pages_have_continue_link(
client_request,
@@ -165,6 +166,7 @@ def test_broadcast_tour_pages_have_continue_link(
pytest.param(3, marks=pytest.mark.xfail),
pytest.param(4, marks=pytest.mark.xfail),
5,
6,
))
def test_broadcast_tour_page_4_shows_service_name(
client_request,
@@ -182,7 +184,7 @@ def test_broadcast_tour_page_4_shows_service_name(
)
@pytest.mark.parametrize('step_index', (0, 6))
@pytest.mark.parametrize('step_index', (0, 7))
def test_broadcast_tour_page_404s_out_of_range(
client_request,
service_one,
@@ -1142,15 +1144,40 @@ def test_view_only_user_cant_approve_broadcast(
assert not page.select_one('.banner a')
@pytest.mark.parametrize('initial_status, expected_approval', (
('draft', False,),
('pending-approval', True),
('rejected', False),
('broadcasting', False),
('cancelled', False),
@pytest.mark.parametrize('trial_mode, initial_status, expected_approval, expected_redirect', (
(True, 'draft', False, partial(
url_for,
'.view_broadcast_message',
broadcast_message_id=sample_uuid,
)),
(True, 'pending-approval', True, partial(
url_for,
'.broadcast_tour',
step_index=6,
)),
(False, 'pending-approval', True, partial(
url_for,
'.view_broadcast_message',
broadcast_message_id=sample_uuid,
)),
(True, 'rejected', False, partial(
url_for,
'.view_broadcast_message',
broadcast_message_id=sample_uuid,
)),
(True, 'broadcasting', False, partial(
url_for,
'.view_broadcast_message',
broadcast_message_id=sample_uuid,
)),
(True, 'cancelled', False, partial(
url_for,
'.view_broadcast_message',
broadcast_message_id=sample_uuid,
)),
))
@freeze_time('2020-02-22T22:22:22.000000')
def test_approve_broadcast(
def test_request_approval(
mocker,
client_request,
service_one,
@@ -1160,6 +1187,8 @@ def test_approve_broadcast(
mock_update_broadcast_message_status,
initial_status,
expected_approval,
trial_mode,
expected_redirect,
):
mocker.patch(
'app.broadcast_message_api_client.get_broadcast_message',
@@ -1172,16 +1201,15 @@ def test_approve_broadcast(
status=initial_status,
),
)
service_one['restricted'] = trial_mode
service_one['permissions'] += ['broadcast']
client_request.post(
'.view_broadcast_message',
service_id=SERVICE_ONE_ID,
broadcast_message_id=fake_uuid,
_expected_redirect=url_for(
'.view_broadcast_message',
_expected_redirect=expected_redirect(
service_id=SERVICE_ONE_ID,
broadcast_message_id=fake_uuid,
_external=True,
)
)