Merge pull request #744 from alphagov/tour-to-dashboard

Go to the dashboard after finishing the tour
This commit is contained in:
Chris Hill-Scott
2016-07-01 14:18:08 +01:00
committed by GitHub
9 changed files with 68 additions and 40 deletions

View File

@@ -76,18 +76,14 @@
@extend %banner; @extend %banner;
background: $govuk-blue; background: $govuk-blue;
color: $white; color: $white;
margin-top: $gutter; margin: 0 0 $gutter 0;
padding: $gutter-half; padding: $gutter-half;
p { p {
margin: 0 0 10px 0; margin: 0 0 10px 0;
} }
&-action { a {
display: block;
text-align: right;
float: right;
&:link, &:link,
&:visited { &:visited {
@@ -107,6 +103,12 @@
} }
&-action {
display: block;
text-align: right;
float: right;
}
} }
.banner-intro { .banner-intro {

View File

@@ -53,13 +53,6 @@ def add_service():
'Hey ((name)), Im trying out Notify. Today is ((day of week)) and my favourite colour is ((colour)).', 'Hey ((name)), Im trying out Notify. Today is ((day of week)) and my favourite colour is ((colour)).',
service_id service_id
) )
example_email_template = service_api_client.create_service_template(
'Example email template',
'email',
'Hey ((name)),\n\nIm trying out Notify. Today is ((day of week)) and my favourite colour is ((colour)).',
service_id,
'Trying out Notify'
)
return redirect(url_for( return redirect(url_for(
'main.send_test', 'main.send_test',

View File

@@ -312,3 +312,15 @@ def start_job(service_id, upload_id):
return redirect( return redirect(
url_for('main.view_job', job_id=upload_id, service_id=service_id, help=request.form.get('help')) url_for('main.view_job', job_id=upload_id, service_id=service_id, help=request.form.get('help'))
) )
@main.route("/services/<service_id>/end-tour/<example_template_id>")
@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)
)

View File

@@ -2,14 +2,14 @@
{% if request.args['help'] and request.args['help'] != '0' %} {% if request.args['help'] and request.args['help'] != '0' %}
{% call banner_wrapper(type='tour') %} {% call banner_wrapper(type='tour') %}
<p class="heading-medium">Get started</p> <p class="heading-medium">Try this example</p>
<div class="grid-row bottom-gutter" {% if request.args['help'] != '1' %}style="opacity: 0.6"{% endif %}> <div class="grid-row bottom-gutter" {% if request.args['help'] != '1' %}style="opacity: 0.6"{% endif %}>
<div class="column-one-sixth"> <div class="column-one-sixth">
<p class="heading-large" style="float: left;">1.</p> <p class="heading-large" style="float: left;">1.</p>
</div> </div>
<div class="column-five-sixths"> <div class="column-five-sixths">
<p> <p>
Send yourself this example message Every message is sent from a template
</p> </p>
</div> </div>
</div> </div>
@@ -29,14 +29,11 @@
</div> </div>
<div class="column-five-sixths"> <div class="column-five-sixths">
<p> <p>
Now try it with your own message Notify delivers the message
</p> </p>
{% if request.args['help'] == '3' %} {% if request.args['help'] == '3' %}
<a href='{{ url_for(".choose_template", service_id=current_service.id, template_type="email") }}'> <a href='{{ url_for(".go_to_dashboard_after_tour", service_id=current_service.id, example_template_id=template.id) }}'>
Write an email Now go to your dashboard
</a>
<a href='{{ url_for(".choose_template", service_id=current_service.id, template_type="sms") }}'>
Write a text message
</a> </a>
{% endif %} {% endif %}
</div> </div>

View File

@@ -10,11 +10,9 @@
<h1 class="visuallyhidden">Dashboard</h1> <h1 class="visuallyhidden">Dashboard</h1>
{% if current_user.has_permissions([ {% if current_user.has_permissions(['manage_templates'], admin_override=True) %}
'manage_templates', 'manage_api_keys', 'manage_users', 'manage_settings {% if not templates %}
'], any_=True, admin_override=True) %} {% include 'views/dashboard/write-first-messages.html' %}
{% if current_service.restricted %}
{% include 'views/dashboard/trial-mode-banner.html' %}
{% endif %} {% endif %}
{% elif not current_user.has_permissions(['send_texts', 'send_emails', 'send_letters'], any_=True) %} {% elif not current_user.has_permissions(['send_texts', 'send_emails', 'send_letters'], any_=True) %}
{% include 'views/dashboard/no-permissions-banner.html' %} {% include 'views/dashboard/no-permissions-banner.html' %}

View File

@@ -1,13 +0,0 @@
{% from "components/banner.html" import banner_wrapper %}
{% from "components/big-number.html" import big_number %}
{% call banner_wrapper(type="mode") %}
<div class="grid-row">
<div class="column-one-half">
Your service is in trial mode
</div>
<div class="column-one-half">
<a href="{{ url_for(".trial_mode") }}" class="banner-mode-action">Find out more<span class="visuallyhidden"> about trial mode</span></a>
</div>
</div>
{% endcall %}

View File

@@ -0,0 +1,16 @@
{% from "components/banner.html" import banner_wrapper %}
<h2 class="heading-medium">Get started</h2>
<nav class="grid-row">
<div class="column-half">
{% call banner_wrapper(type="mode") %}
<a href="{{ url_for('.choose_template', service_id=current_service.id, template_type='email') }}">Write an email
{% endcall %}
</div>
<div class="column-half">
{% call banner_wrapper(type="mode") %}
<a href="{{ url_for('.choose_template', service_id=current_service.id, template_type='email') }}">Write a text message</a>
{% endcall %}
</div>
</nav>

View File

@@ -35,7 +35,7 @@ def test_should_add_service_and_redirect_to_tour_when_no_services(app_,
user_id=api_user_active.id, user_id=api_user_active.id,
email_from='testing.the.post' email_from='testing.the.post'
) )
assert len(mock_create_service_template.call_args_list) == 2 assert len(mock_create_service_template.call_args_list) == 1
assert session['service_id'] == 101 assert session['service_id'] == 101
assert response.status_code == 302 assert response.status_code == 302
assert response.location == url_for( assert response.location == url_for(

View File

@@ -696,3 +696,26 @@ def test_send_and_check_page_renders_if_no_statistics(
page = BeautifulSoup(resp.data.decode('utf-8'), 'html.parser') page = BeautifulSoup(resp.data.decode('utf-8'), 'html.parser')
assert page.h1.text.strip() == 'Check and confirm' assert page.h1.text.strip() == 'Check and confirm'
mock_get_stats.assert_called_once_with(fake_uuid, today) 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)