From 684d4f7782bd400b3d024a54c0608374bfef49ec Mon Sep 17 00:00:00 2001 From: Chris Hill-Scott Date: Mon, 5 Nov 2018 12:16:38 +0000 Subject: [PATCH] Refactor setting value on letter branding form MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit WTForms lets you pre-populate a form’s value by passing it in as an argument to the constructor. This will be good for us because it will let us access that value in the constructor later on. --- app/main/views/service_settings.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/app/main/views/service_settings.py b/app/main/views/service_settings.py index 25e2f29c3..0801167bf 100644 --- a/app/main/views/service_settings.py +++ b/app/main/views/service_settings.py @@ -876,7 +876,10 @@ def service_preview_email_branding(service_id): @user_is_platform_admin def set_letter_branding(service_id): - form = LetterBranding(choices=email_branding_client.get_letter_email_branding().items()) + form = LetterBranding( + choices=email_branding_client.get_letter_email_branding().items(), + dvla_org_id=current_service.dvla_organisation, + ) if form.validate_on_submit(): service_api_client.update_service( @@ -885,8 +888,6 @@ def set_letter_branding(service_id): ) return redirect(url_for('.service_settings', service_id=service_id)) - form.dvla_org_id.data = current_service.dvla_organisation - return render_template( 'views/service-settings/set-letter-branding.html', form=form,