mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-09-07 16:28:25 -04:00
Reduce usage of the platform admin index page
This page is slow to load which means: - it’s annoying for us - it’s potentially causing load on the database This commit does two things to reduce the amount we’re unnecessarily looking at this page: 1. Avoid redirecting to it when signing in as a platform admin user 2. Don’t go directly to it when clicking ‘platform admin’ at the top, but instead show a holding page (there’s a fair chance you’ve clicked that link in order to go and manage some email branding or find a user, not wait for stats to load)
This commit is contained in:
@@ -42,6 +42,14 @@ ZERO_FAILURE_THRESHOLD = 0
|
|||||||
|
|
||||||
@main.route("/platform-admin")
|
@main.route("/platform-admin")
|
||||||
@user_is_platform_admin
|
@user_is_platform_admin
|
||||||
|
def platform_admin_splash_page():
|
||||||
|
return render_template(
|
||||||
|
'views/platform-admin/splash-page.html',
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@main.route("/platform-admin/summary")
|
||||||
|
@user_is_platform_admin
|
||||||
def platform_admin():
|
def platform_admin():
|
||||||
form = DateFilterForm(request.args, meta={'csrf': False})
|
form = DateFilterForm(request.args, meta={'csrf': False})
|
||||||
api_args = {}
|
api_args = {}
|
||||||
|
|||||||
@@ -111,7 +111,5 @@ def redirect_when_logged_in(platform_admin):
|
|||||||
next_url = request.args.get('next')
|
next_url = request.args.get('next')
|
||||||
if next_url and _is_safe_redirect_url(next_url):
|
if next_url and _is_safe_redirect_url(next_url):
|
||||||
return redirect(next_url)
|
return redirect(next_url)
|
||||||
if platform_admin:
|
|
||||||
return redirect(url_for('main.platform_admin'))
|
|
||||||
|
|
||||||
return redirect(url_for('main.show_accounts_or_dashboard'))
|
return redirect(url_for('main.show_accounts_or_dashboard'))
|
||||||
|
|||||||
@@ -101,6 +101,7 @@ class HeaderNavigation(Navigation):
|
|||||||
'platform_admin_list_complaints',
|
'platform_admin_list_complaints',
|
||||||
'platform_admin_reports',
|
'platform_admin_reports',
|
||||||
'platform_admin_returned_letters',
|
'platform_admin_returned_letters',
|
||||||
|
'platform_admin_splash_page',
|
||||||
'suspend_service',
|
'suspend_service',
|
||||||
'trial_services',
|
'trial_services',
|
||||||
'update_email_branding',
|
'update_email_branding',
|
||||||
@@ -580,6 +581,7 @@ class MainNavigation(Navigation):
|
|||||||
'platform_admin_list_complaints',
|
'platform_admin_list_complaints',
|
||||||
'platform_admin_reports',
|
'platform_admin_reports',
|
||||||
'platform_admin_returned_letters',
|
'platform_admin_returned_letters',
|
||||||
|
'platform_admin_splash_page',
|
||||||
'pricing',
|
'pricing',
|
||||||
'privacy',
|
'privacy',
|
||||||
'public_agreement',
|
'public_agreement',
|
||||||
@@ -828,6 +830,7 @@ class CaseworkNavigation(Navigation):
|
|||||||
'platform_admin_reports',
|
'platform_admin_reports',
|
||||||
'platform_admin_returned_letters',
|
'platform_admin_returned_letters',
|
||||||
'platform_admin',
|
'platform_admin',
|
||||||
|
'platform_admin_splash_page',
|
||||||
'pricing',
|
'pricing',
|
||||||
'privacy',
|
'privacy',
|
||||||
'public_agreement',
|
'public_agreement',
|
||||||
@@ -1117,6 +1120,7 @@ class OrgNavigation(Navigation):
|
|||||||
'platform_admin_list_complaints',
|
'platform_admin_list_complaints',
|
||||||
'platform_admin_reports',
|
'platform_admin_reports',
|
||||||
'platform_admin_returned_letters',
|
'platform_admin_returned_letters',
|
||||||
|
'platform_admin_splash_page',
|
||||||
'pricing',
|
'pricing',
|
||||||
'privacy',
|
'privacy',
|
||||||
'public_agreement',
|
'public_agreement',
|
||||||
|
|||||||
@@ -55,7 +55,7 @@
|
|||||||
"active": header_navigation.is_selected('user-profile')
|
"active": header_navigation.is_selected('user-profile')
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"href": url_for('main.platform_admin'),
|
"href": url_for('main.platform_admin_splash_page'),
|
||||||
"text": "Platform admin",
|
"text": "Platform admin",
|
||||||
"active": header_navigation.is_selected('platform-admin')
|
"active": header_navigation.is_selected('platform-admin')
|
||||||
},
|
},
|
||||||
|
|||||||
17
app/templates/views/platform-admin/splash-page.html
Normal file
17
app/templates/views/platform-admin/splash-page.html
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
{% extends "views/platform-admin/_base_template.html" %}
|
||||||
|
|
||||||
|
{% block per_page_title %}
|
||||||
|
Summary
|
||||||
|
{% endblock %}
|
||||||
|
|
||||||
|
{% block platform_admin_content %}
|
||||||
|
|
||||||
|
<h1 class="heading-large">
|
||||||
|
Summary
|
||||||
|
</h1>
|
||||||
|
|
||||||
|
<p class="govuk-body">
|
||||||
|
<a class="govuk-link govuk-link--no-visited-state" href="{{ url_for('main.platform_admin') }}">Load summary</a>
|
||||||
|
</p>
|
||||||
|
|
||||||
|
{% endblock %}
|
||||||
@@ -37,6 +37,7 @@ def test_should_redirect_if_not_logged_in(
|
|||||||
|
|
||||||
@pytest.mark.parametrize('endpoint', [
|
@pytest.mark.parametrize('endpoint', [
|
||||||
'main.platform_admin',
|
'main.platform_admin',
|
||||||
|
'main.platform_admin_splash_page',
|
||||||
'main.live_services',
|
'main.live_services',
|
||||||
'main.trial_services',
|
'main.trial_services',
|
||||||
])
|
])
|
||||||
@@ -589,6 +590,20 @@ def test_get_tech_failure_status_box_data_removes_percentage_data():
|
|||||||
assert 'percentage' not in tech_failure_data
|
assert 'percentage' not in tech_failure_data
|
||||||
|
|
||||||
|
|
||||||
|
def test_platform_admin_splash_doesnt_talk_to_api(
|
||||||
|
client_request,
|
||||||
|
platform_admin_user,
|
||||||
|
):
|
||||||
|
|
||||||
|
client_request.login(platform_admin_user)
|
||||||
|
|
||||||
|
page = client_request.get('main.platform_admin_splash_page')
|
||||||
|
|
||||||
|
assert page.select_one('main .govuk-body a')['href'] == url_for(
|
||||||
|
'main.platform_admin',
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
def test_platform_admin_with_start_and_end_dates_provided(mocker, platform_admin_client):
|
def test_platform_admin_with_start_and_end_dates_provided(mocker, platform_admin_client):
|
||||||
start_date = '2018-01-01'
|
start_date = '2018-01-01'
|
||||||
end_date = '2018-06-01'
|
end_date = '2018-06-01'
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
import pytest
|
||||||
from bs4 import BeautifulSoup
|
from bs4 import BeautifulSoup
|
||||||
from flask import url_for
|
from flask import url_for
|
||||||
from freezegun import freeze_time
|
from freezegun import freeze_time
|
||||||
@@ -107,6 +108,9 @@ def test_should_login_user_and_not_redirect_to_external_url(
|
|||||||
assert response.location == url_for('main.show_accounts_or_dashboard', _external=True)
|
assert response.location == url_for('main.show_accounts_or_dashboard', _external=True)
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.parametrize('platform_admin', (
|
||||||
|
True, False,
|
||||||
|
))
|
||||||
@freeze_time('2020-01-27T12:00:00')
|
@freeze_time('2020-01-27T12:00:00')
|
||||||
def test_should_login_user_and_redirect_to_show_accounts(
|
def test_should_login_user_and_redirect_to_show_accounts(
|
||||||
client,
|
client,
|
||||||
@@ -115,12 +119,14 @@ def test_should_login_user_and_redirect_to_show_accounts(
|
|||||||
mock_get_user_by_email,
|
mock_get_user_by_email,
|
||||||
mock_check_verify_code,
|
mock_check_verify_code,
|
||||||
mock_create_event,
|
mock_create_event,
|
||||||
|
platform_admin,
|
||||||
):
|
):
|
||||||
with client.session_transaction() as session:
|
with client.session_transaction() as session:
|
||||||
session['user_details'] = {
|
session['user_details'] = {
|
||||||
'id': api_user_active['id'],
|
'id': api_user_active['id'],
|
||||||
'email': api_user_active['email_address']}
|
'email': api_user_active['email_address']}
|
||||||
api_user_active['email_access_validated_at'] = '2020-01-23T11:35:21.726132Z'
|
api_user_active['email_access_validated_at'] = '2020-01-23T11:35:21.726132Z'
|
||||||
|
api_user_active['platform_admin'] = platform_admin
|
||||||
|
|
||||||
response = client.post(url_for('main.two_factor'),
|
response = client.post(url_for('main.two_factor'),
|
||||||
data={'sms_code': '12345'})
|
data={'sms_code': '12345'})
|
||||||
|
|||||||
Reference in New Issue
Block a user