Put the currently selected branding top of list

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.
This commit is contained in:
Chris Hill-Scott
2018-08-31 17:21:12 +01:00
parent 405d459607
commit 80801d827a

View File

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