From 2f711b52ea0dd1f3fb7504c8544f29977e55c608 Mon Sep 17 00:00:00 2001 From: Chris Hill-Scott Date: Fri, 7 Jun 2019 10:16:21 +0100 Subject: [PATCH] Refactor choose service page into macros This makes it easier to see the logic controlling which services are shown where because the repetitive loops have been factored out. --- app/templates/views/choose-account.html | 104 +++++++++--------- .../views/accounts/test_choose_accounts.py | 2 +- 2 files changed, 56 insertions(+), 50 deletions(-) diff --git a/app/templates/views/choose-account.html b/app/templates/views/choose-account.html index fb9da0802..d1d0bbeb4 100644 --- a/app/templates/views/choose-account.html +++ b/app/templates/views/choose-account.html @@ -1,5 +1,29 @@ {% extends "withoutnav_template.html" %} +{% macro service_list(heading, show_heading, organisations=[], services=[]) %} + {% if show_heading %} +

+ {{ heading }} +

+ {% endif %} + +{% endmacro %} + {% block per_page_title %} Choose service {% endblock %} @@ -10,58 +34,40 @@ Choose service {% if can_add_service %}
diff --git a/tests/app/main/views/accounts/test_choose_accounts.py b/tests/app/main/views/accounts/test_choose_accounts.py index d26dacf42..ead1a283c 100644 --- a/tests/app/main/views/accounts/test_choose_accounts.py +++ b/tests/app/main/views/accounts/test_choose_accounts.py @@ -89,7 +89,7 @@ def test_choose_account_should_show_choose_accounts_page( assert outer_list_items[4].a.text == 'service_2' assert outer_list_items[4].a['href'] == url_for('.service_dashboard', service_id='s2') - # orphaned live services + # orphaned trial services trial_services_list_items = page.select('nav ul')[1].select('li') assert len(trial_services_list_items) == 2 assert trial_services_list_items[0].a.text == 'org_service_3'