From 016f38db9b90f28b361e7883cef46dc36fdfbd06 Mon Sep 17 00:00:00 2001 From: Chris Hill-Scott Date: Wed, 19 May 2021 09:39:38 +0100 Subject: [PATCH] Refactor service name code to reduce duplication MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This makes the code shareable between: - the broadcast tour pages - the broadcast settings platform admin page - the regular service navigation On the training mode tour pages we don’t want to confuse people with the organisation name or _Switch service_ links, so those are omitted and the code is therefore slightly different. --- app/templates/service_navigation.html | 57 ++++++++++++------- app/templates/views/broadcast/tour/5.html | 5 +- app/templates/views/broadcast/tour/6.html | 6 +- ...ervice-confirm-broadcast-account-type.html | 28 +++------ tests/app/main/views/test_broadcast.py | 9 ++- 5 files changed, 53 insertions(+), 52 deletions(-) diff --git a/app/templates/service_navigation.html b/app/templates/service_navigation.html index 6e87d50cd..8fb5bfc19 100644 --- a/app/templates/service_navigation.html +++ b/app/templates/service_navigation.html @@ -1,3 +1,37 @@ +{% macro navigation_service_name(service) %} + +{% endmacro %} + +{% macro broadcast_service_name_tag(trial_mode, broadcast_channel, allowed_broadcast_provider, left_margin=True) %} + {% set margin_class = "" if left_margin else "govuk-!-margin-left-0" %} + {% if trial_mode %} + Training + {% elif broadcast_channel == 'severe' %} + Live + {% elif broadcast_channel == 'test' %} + {{ broadcast_channel|title }} + {% if allowed_broadcast_provider == "all" %} + (all networks) + {% else %} + ({{ allowed_broadcast_provider|format_mobile_network }}) + {% endif %} + {% elif broadcast_channel == 'government' %} + Government + {% endif %} + +{% endmacro %} + diff --git a/app/templates/views/broadcast/tour/5.html b/app/templates/views/broadcast/tour/5.html index e1fa138de..2e35a9aec 100644 --- a/app/templates/views/broadcast/tour/5.html +++ b/app/templates/views/broadcast/tour/5.html @@ -1,4 +1,5 @@ {% from "components/banner.html" import banner_wrapper %} +{% from "service_navigation.html" import navigation_service_name %} {% extends "admin_template.html" %} @@ -11,9 +12,7 @@ {% block content %}