From 88fff50ea338947760cb97d93cb93c28907aa9c3 Mon Sep 17 00:00:00 2001 From: Chris Hill-Scott Date: Mon, 12 Sep 2016 11:38:16 +0100 Subject: [PATCH] Split platform admin page into live and trial mode It sucks having to scroll down the massive list of services just to see which ones are live. --- app/main/views/platform_admin.py | 7 ++++++- app/templates/views/platform-admin.html | 6 +++--- tests/app/main/views/test_platform_admin.py | 16 +++++++++------- 3 files changed, 18 insertions(+), 11 deletions(-) diff --git a/app/main/views/platform_admin.py b/app/main/views/platform_admin.py index ca753782a..2ca78641a 100644 --- a/app/main/views/platform_admin.py +++ b/app/main/views/platform_admin.py @@ -25,7 +25,12 @@ def platform_admin(): def get_statistics(services): return { 'global_stats': create_global_stats(services), - 'service_stats': format_stats_by_service(services) + 'live_services': format_stats_by_service([ + service for service in services if not service['restricted'] + ]), + 'trial_mode_services': format_stats_by_service([ + service for service in services if service['restricted'] + ]), } diff --git a/app/templates/views/platform-admin.html b/app/templates/views/platform-admin.html index 519ecb4ec..38902bc7d 100644 --- a/app/templates/views/platform-admin.html +++ b/app/templates/views/platform-admin.html @@ -8,7 +8,7 @@ {% call(item, row_number) list_table( services, caption=caption, - caption_visible=False, + caption_visible=True, field_headings=[ 'Service', hidden_field_heading('Status'), @@ -89,8 +89,8 @@ -

Services

+ {{ services_table(live_services, 'Live services') }} - {{ services_table(service_stats, 'All services') }} + {{ services_table(trial_mode_services, 'Trial mode services') }} {% endblock %} diff --git a/tests/app/main/views/test_platform_admin.py b/tests/app/main/views/test_platform_admin.py index a6b92979e..ca95d704a 100644 --- a/tests/app/main/views/test_platform_admin.py +++ b/tests/app/main/views/test_platform_admin.py @@ -30,14 +30,15 @@ def test_should_403_if_not_platform_admin(app_, active_user_with_permissions, mo assert response.status_code == 403 -@pytest.mark.parametrize('restricted, research_mode, displayed', [ - (True, False, ''), - (False, False, 'Live'), - (False, True, 'research mode'), - (True, True, 'research mode') +@pytest.mark.parametrize('restricted, table_index, research_mode, displayed', [ + (True, 1, False, ''), + (False, 0, False, 'Live'), + (False, 0, True, 'research mode'), + (True, 1, True, 'research mode') ]) def test_should_show_research_and_restricted_mode( restricted, + table_index, research_mode, displayed, app_, @@ -60,7 +61,7 @@ def test_should_show_research_and_restricted_mode( mock_get_detailed_services.assert_called_once_with({'detailed': True}) page = BeautifulSoup(response.data.decode('utf-8'), 'html.parser') # get second column, which contains flags as text. - assert page.tbody.select('td:nth-of-type(2)')[0].text.strip() == displayed + assert page.find_all('tbody')[table_index].find_all('td')[1].text.strip() == displayed def test_should_render_platform_admin_page( @@ -79,7 +80,8 @@ def test_should_render_platform_admin_page( resp_data = response.get_data(as_text=True) assert 'Platform admin' in resp_data assert 'Today' in resp_data - assert 'Services' in resp_data + assert 'Live services' in resp_data + assert 'Trial mode services' in resp_data mock_get_detailed_services.assert_called_once_with({'detailed': True})