Refactor setting value on letter branding form

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.
This commit is contained in:
Chris Hill-Scott
2018-11-05 12:16:38 +00:00
parent 72ddd107ef
commit 684d4f7782

View File

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