From 37f341e757e5a5a342954eb348103a37b9d4c1d2 Mon Sep 17 00:00:00 2001
From: Chris Hill-Scott
Date: Tue, 19 Apr 2016 10:30:15 +0100
Subject: [PATCH] Make tour work for non-logged-in users
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
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
---
app/main/views/add_service.py | 2 +-
app/main/views/dashboard.py | 2 +-
app/main/views/tour.py | 5 ++---
app/templates/views/tour/1.html | 2 +-
app/templates/views/tour/2.html | 2 +-
app/templates/views/tour/3.html | 2 +-
app/templates/views/tour/4.html | 2 +-
tests/app/main/views/test_add_service.py | 2 +-
tests/app/main/views/test_tour.py | 3 +--
9 files changed, 10 insertions(+), 12 deletions(-)
diff --git a/app/main/views/add_service.py b/app/main/views/add_service.py
index 3a6d7722f..432eee2ea 100644
--- a/app/main/views/add_service.py
+++ b/app/main/views/add_service.py
@@ -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',
diff --git a/app/main/views/dashboard.py b/app/main/views/dashboard.py
index 81d1caeed..7271a32bf 100644
--- a/app/main/views/dashboard.py
+++ b/app/main/views/dashboard.py
@@ -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))
diff --git a/app/main/views/tour.py b/app/main/views/tour.py
index a1a98300f..3ab1756df 100644
--- a/app/main/views/tour.py
+++ b/app/main/views/tour.py
@@ -12,9 +12,8 @@ headings = [
]
-@main.route("/services//tour/")
-@login_required
-def tour(service_id, page):
+@main.route("/tour/")
+def tour(page):
return render_template(
'views/tour/{}.html'.format(page),
current_page=page,
diff --git a/app/templates/views/tour/1.html b/app/templates/views/tour/1.html
index 2c3df7ad3..1474c8825 100644
--- a/app/templates/views/tour/1.html
+++ b/app/templates/views/tour/1.html
@@ -17,7 +17,7 @@
We can remove these restrictions when you’re ready.
-
+
Next
{% endcall %}
diff --git a/app/templates/views/tour/2.html b/app/templates/views/tour/2.html
index d8508538a..fd321e927 100644
--- a/app/templates/views/tour/2.html
+++ b/app/templates/views/tour/2.html
@@ -29,7 +29,7 @@
>
-
+
Next
{% endcall %}
diff --git a/app/templates/views/tour/3.html b/app/templates/views/tour/3.html
index 4bcd6a4da..c6138148b 100644
--- a/app/templates/views/tour/3.html
+++ b/app/templates/views/tour/3.html
@@ -32,7 +32,7 @@
Developers, you can add data automatically using an API
-
+
Next
{% endcall %}
diff --git a/app/templates/views/tour/4.html b/app/templates/views/tour/4.html
index e976214e8..2b845d0fa 100644
--- a/app/templates/views/tour/4.html
+++ b/app/templates/views/tour/4.html
@@ -14,7 +14,7 @@
Notify merges your data with the template and sends the messages
-
+
Next
diff --git a/tests/app/main/views/test_add_service.py b/tests/app/main/views/test_add_service.py
index 4162282fc..32e110b5c 100644
--- a/tests/app/main/views/test_add_service.py
+++ b/tests/app/main/views/test_add_service.py
@@ -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,
diff --git a/tests/app/main/views/test_tour.py b/tests/app/main/views/test_tour.py
index 0b2249eeb..1ab05ade8 100644
--- a/tests/app/main/views/test_tour.py
+++ b/tests/app/main/views/test_tour.py
@@ -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)