From 80801d827a10ae5d4c3d0b2c69a8bbbd6b7f5466 Mon Sep 17 00:00:00 2001 From: Chris Hill-Scott Date: Fri, 31 Aug 2018 17:21:12 +0100 Subject: [PATCH] Put the currently selected branding top of list MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit There’s something that feels a bit off about not being able to see the name of the currently-selected branding when you land on the page. Putting it at the top also means that you can easily switch back to it if you change your mind. --- app/main/views/service_settings.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/app/main/views/service_settings.py b/app/main/views/service_settings.py index 589ced108..d8a86b54d 100644 --- a/app/main/views/service_settings.py +++ b/app/main/views/service_settings.py @@ -890,9 +890,14 @@ def service_set_email_branding(service_id): form = ServiceSetBranding() # dynamically create org choices, including the null option - email_brandings = sorted(get_branding_as_value_and_label(email_branding), - key=lambda tup: tup[1].lower()) - form.branding_style.choices = [('None', 'GOV.UK')] + email_brandings + form.branding_style.choices = sorted( + get_branding_as_value_and_label(email_branding) + [('None', 'GOV.UK')], + key=lambda branding: ( + branding[0] != current_service.email_branding, + branding[0] is not 'None', + branding[1].lower(), + ), + ) if form.validate_on_submit(): branding_style = None if form.branding_style.data == 'None' else form.branding_style.data