From 721212816db5a009648c24625adce4724d194cf4 Mon Sep 17 00:00:00 2001 From: Chris Hill-Scott Date: Fri, 1 Jul 2016 10:49:54 +0100 Subject: [PATCH] Redirect to the dashboard after the tour MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit After the tour we should ground users by dropping them on the dashboard. In the background, we delete the example text message template. This means that users start from a clean slate when they go to add their own templates This also means some wording changes to the tour so it still makes (some) sense: - 1, 2 and 3 should refer to the current step, not describe the next one - the link should take you to the dashboard - change from ‘Get started’ to ‘Try this example’ because we’re using ‘Get started on the dashboard’ --- app/main/views/send.py | 12 ++++++++++++ app/templates/main_nav.html | 13 +++++-------- tests/app/main/views/test_send.py | 23 +++++++++++++++++++++++ 3 files changed, 40 insertions(+), 8 deletions(-) diff --git a/app/main/views/send.py b/app/main/views/send.py index 4615491a9..c3a0fcb2f 100644 --- a/app/main/views/send.py +++ b/app/main/views/send.py @@ -312,3 +312,15 @@ def start_job(service_id, upload_id): return redirect( url_for('main.view_job', job_id=upload_id, service_id=service_id, help=request.form.get('help')) ) + + +@main.route("/services//end-tour/") +@login_required +@user_has_permissions('manage_templates') +def go_to_dashboard_after_tour(service_id, example_template_id): + + service_api_client.delete_service_template(service_id, example_template_id) + + return redirect( + url_for('main.service_dashboard', service_id=service_id) + ) diff --git a/app/templates/main_nav.html b/app/templates/main_nav.html index 733379e1d..1fdfb461c 100644 --- a/app/templates/main_nav.html +++ b/app/templates/main_nav.html @@ -2,14 +2,14 @@ {% if request.args['help'] and request.args['help'] != '0' %} {% call banner_wrapper(type='tour') %} -

Get started

+

Try this example

1.

- Send yourself this example message + Every message is sent from a template

@@ -29,14 +29,11 @@

- Now try it with your own message + Notify delivers the message

{% if request.args['help'] == '3' %} - - Write an email - - - Write a text message + + Now go to your dashboard {% endif %}
diff --git a/tests/app/main/views/test_send.py b/tests/app/main/views/test_send.py index 753a205f5..4f3f431a3 100644 --- a/tests/app/main/views/test_send.py +++ b/tests/app/main/views/test_send.py @@ -696,3 +696,26 @@ def test_send_and_check_page_renders_if_no_statistics( page = BeautifulSoup(resp.data.decode('utf-8'), 'html.parser') assert page.h1.text.strip() == 'Check and confirm' mock_get_stats.assert_called_once_with(fake_uuid, today) + + +def test_go_to_dashboard_after_tour( + app_, + mocker, + api_user_active, + mock_login, + mock_get_service, + mock_has_permissions, + mock_delete_service_template, + fake_uuid +): + + with app_.test_request_context(), app_.test_client() as client: + client.login(api_user_active) + + resp = client.get( + url_for('main.go_to_dashboard_after_tour', service_id=fake_uuid, example_template_id=fake_uuid) + ) + + assert resp.status_code == 302 + assert resp.location == url_for("main.service_dashboard", service_id=fake_uuid, _external=True) + mock_delete_service_template.assert_called_once_with(fake_uuid, fake_uuid)