From 95482363aa8d99081897bf67603974481c861924 Mon Sep 17 00:00:00 2001 From: Chris Hill-Scott Date: Wed, 14 Feb 2018 10:38:00 +0000 Subject: [PATCH] Remove dashboard from dashboard URL MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit It’s weird that `/services/` returns `404`. The home page for every service is the dashboard – should be possible to get there from any other page just by stemming the URL. Also makes it consistent with organisations, which will have `/organisations/`. --- app/main/views/dashboard.py | 7 +++++++ tests/app/main/views/test_dashboard.py | 13 +++++++++++++ tests/app/main/views/test_two_factor.py | 2 +- 3 files changed, 21 insertions(+), 1 deletion(-) diff --git a/app/main/views/dashboard.py b/app/main/views/dashboard.py index f12543efd..56d89d80f 100644 --- a/app/main/views/dashboard.py +++ b/app/main/views/dashboard.py @@ -51,6 +51,13 @@ def temp_service_history(service_id): @main.route("/services//dashboard") @login_required @user_has_permissions('view_activity', admin_override=True) +def old_service_dashboard(service_id): + return redirect(url_for('.service_dashboard', service_id=service_id)) + + +@main.route("/services/") +@login_required +@user_has_permissions('view_activity', admin_override=True) def service_dashboard(service_id): if session.get('invited_user'): diff --git a/tests/app/main/views/test_dashboard.py b/tests/app/main/views/test_dashboard.py index 7e09c5fc5..3cc60d697 100644 --- a/tests/app/main/views/test_dashboard.py +++ b/tests/app/main/views/test_dashboard.py @@ -42,6 +42,19 @@ stub_template_stats = [ ] +def test_redirect_from_old_dashboard( + logged_in_client +): + + expected_location = 'http://localhost/services/{}'.format(SERVICE_ONE_ID) + + response = logged_in_client.get('/services/{}/dashboard'.format(SERVICE_ONE_ID)) + + assert response.status_code == 302 + assert response.location == expected_location + assert expected_location == url_for('main.service_dashboard', service_id=SERVICE_ONE_ID, _external=True) + + def test_get_started( logged_in_client, mocker, diff --git a/tests/app/main/views/test_two_factor.py b/tests/app/main/views/test_two_factor.py index f9a3b0686..4172627b2 100644 --- a/tests/app/main/views/test_two_factor.py +++ b/tests/app/main/views/test_two_factor.py @@ -59,7 +59,7 @@ def test_should_login_user_and_should_redirect_to_next_url( session['user_details'] = { 'id': api_user_active.id, 'email': api_user_active.email_address} - response = client.post(url_for('main.two_factor', next='/services/{}/dashboard'.format(SERVICE_ONE_ID)), + response = client.post(url_for('main.two_factor', next='/services/{}'.format(SERVICE_ONE_ID)), data={'sms_code': '12345'}) assert response.status_code == 302 assert response.location == url_for(