Merge pull request #2235 from alphagov/sort-branding-radios-alphabetically

Sort branding radios alphabetically
This commit is contained in:
Tom Byers
2018-08-16 16:49:12 +01:00
committed by GitHub
6 changed files with 58 additions and 26 deletions

View File

@@ -26,10 +26,11 @@ from app.utils import get_cdn_domain, user_is_platform_admin
@login_required
@user_is_platform_admin
def email_branding():
brandings = email_branding_client.get_all_email_branding()
brandings = email_branding_client.get_all_email_branding(sort_key='name')
form = ServiceSelectEmailBranding()
form.email_branding.choices = get_branding_as_value_and_label(brandings) + [('None', 'Create a new email branding')]
email_brandings = get_branding_as_value_and_label(brandings)
form.email_branding.choices = email_brandings + [('None', 'Create a new email branding')]
if form.validate_on_submit():
if form.email_branding.data != 'None':

View File

@@ -872,7 +872,9 @@ def service_set_email_branding(service_id):
form = ServiceSetBranding(branding_type=branding_type)
# dynamically create org choices, including the null option
form.branding_style.choices = [('None', 'None')] + get_branding_as_value_and_label(email_branding)
email_brandings = sorted(get_branding_as_value_and_label(email_branding),
key=lambda tup: tup[1].lower())
form.branding_style.choices = [('None', 'None')] + email_brandings
if form.validate_on_submit():
branding_style = None if form.branding_style.data == 'None' else form.branding_style.data