Make tour work for non-logged-in users

There’s no content in the tour that’s specific to a service. And since
we can now take a pretty good guess at what service you last used, or
which service we should send you to if you only have one service,
there’s no need to make the URLs for the tour service-specific.

This also means that you don’t need to be logged in to see the tour
pages, and we have no good reason to only restrict these pages to users
with accounts.

https://www.pivotaltracker.com/story/show/116960703
This commit is contained in:
Chris Hill-Scott
2016-04-19 10:30:15 +01:00
parent c2b96be247
commit 37f341e757
9 changed files with 10 additions and 12 deletions

View File

@@ -43,7 +43,7 @@ def add_service():
user_id=session['user_id'],
email_from=email_from)
return redirect(url_for('main.tour', service_id=service_id, page=1))
return redirect(url_for('main.tour', page=1))
else:
return render_template(
'views/add-service.html',

View File

@@ -34,7 +34,7 @@ def service_dashboard(service_id):
if session.get('invited_user'):
session.pop('invited_user', None)
return redirect(url_for("main.tour", service_id=service_id, page=1))
return redirect(url_for("main.tour", page=1))
statistics = statistics_api_client.get_statistics_for_service(service_id)['data']
template_statistics = aggregate_usage(template_statistics_client.get_template_statistics_for_service(service_id))

View File

@@ -12,9 +12,8 @@ headings = [
]
@main.route("/services/<service_id>/tour/<int:page>")
@login_required
def tour(service_id, page):
@main.route("/tour/<int:page>")
def tour(page):
return render_template(
'views/tour/{}.html'.format(page),
current_page=page,

View File

@@ -17,7 +17,7 @@
<p>
We can remove these restrictions when youre ready.
</p>
<a href='{{ url_for('.tour', service_id=current_service.id, page=next_page) }}'>
<a href='{{ url_for('.tour', page=next_page) }}'>
Next
</a>
{% endcall %}

View File

@@ -29,7 +29,7 @@
>
</picture>
</p>
<a href='{{ url_for('.tour', service_id=current_service.id, page=next_page) }}'>
<a href='{{ url_for('.tour', page=next_page) }}'>
Next
</a>
{% endcall %}

View File

@@ -32,7 +32,7 @@
<p>
Developers, you can add data automatically using an API
</p>
<a href='{{ url_for('.tour', service_id=current_service.id, page=next_page) }}'>
<a href='{{ url_for('.tour', page=next_page) }}'>
Next
</a>
{% endcall %}

View File

@@ -14,7 +14,7 @@
<p>
Notify merges your data with the template and sends the messages
</p>
<a href="{{ url_for('.service_dashboard', service_id=current_service.id) }}">
<a href="{{ url_for('.show_all_services_or_dashboard') }}">
Next
</a>
<picture class="banner-tour-image-flush-bottom">

View File

@@ -26,7 +26,7 @@ def test_should_add_service_and_redirect_to_next_page(app_,
url_for('main.add_service'),
data={'name': 'testing the post'})
assert response.status_code == 302
assert response.location == url_for('main.tour', service_id=101, page=1, _external=True)
assert response.location == url_for('main.tour', page=1, _external=True)
assert mock_get_services.called
mock_create_service.asset_called_once_with(service_name='testing the post',
active=False,

View File

@@ -14,7 +14,6 @@ def test_should_render_tour_pages(
):
with app_.test_request_context():
with app_.test_client() as client:
client.login(api_user_active, mocker)
response = client.get(url_for('main.tour', service_id=101, page=page))
response = client.get(url_for('main.tour', page=page))
assert response.status_code == 200
assert 'Next' in response.get_data(as_text=True)