From 3c0f06a36df8194c17ef0c54d3c8b75650aac0d2 Mon Sep 17 00:00:00 2001 From: Leo Hemsted Date: Mon, 15 Aug 2016 10:39:27 +0100 Subject: [PATCH] set value of radio input to be org id also don't use nil, this isn't ruby --- app/main/views/service_settings.py | 8 ++++---- app/templates/components/radios.html | 1 + 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/app/main/views/service_settings.py b/app/main/views/service_settings.py index e5b341533..503fc9497 100644 --- a/app/main/views/service_settings.py +++ b/app/main/views/service_settings.py @@ -276,10 +276,10 @@ def service_set_branding_and_org(service_id): form = ServiceBrandingOrg(branding_type=current_service.get('branding')) # dynamically create org choices, including the null option - form.organisation.choices = [('nil', 'None')] + get_branding_as_value_and_label(organisations) + form.organisation.choices = [('None', 'None')] + get_branding_as_value_and_label(organisations) if form.validate_on_submit(): - organisation = None if form.organisation.data == 'nil' else form.organisation.data + organisation = None if form.organisation.data == 'None' else form.organisation.data service_api_client.update_service( service_id, branding=form.branding_type.data, @@ -287,8 +287,8 @@ def service_set_branding_and_org(service_id): ) return redirect(url_for('.service_settings', service_id=service_id)) - # only set form.organisation.data on GET (to select correct initial radio button) - form.organisation.data = current_service['organisation'] or 'nil' + form.organisation.data = current_service['organisation'] or 'None' + return render_template( 'views/service-settings/set-branding-and-org.html', form=form, diff --git a/app/templates/components/radios.html b/app/templates/components/radios.html index 59061f5dd..2fba0f566 100644 --- a/app/templates/components/radios.html +++ b/app/templates/components/radios.html @@ -44,6 +44,7 @@ type="radio" name="{{ field.name }}" id="{{ field.name }}-{{ loop.index }}" + value="{{ value }}" {% if checked %}checked="checked"{% endif %} /> {% if branding_dict.get(value, {}).get('colour') %}