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.
This commit is contained in:
Chris Hill-Scott
2016-09-12 11:38:16 +01:00
parent 29d5bc4f51
commit 88fff50ea3
3 changed files with 18 additions and 11 deletions

View File

@@ -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']
]),
}

View File

@@ -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 @@
</div>
</div>
<h2 class='heading-medium visually-hidden'>Services</h2>
{{ services_table(live_services, 'Live services') }}
{{ services_table(service_stats, 'All services') }}
{{ services_table(trial_mode_services, 'Trial mode services') }}
{% endblock %}

View File

@@ -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})