mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-08-18 05:29:38 -04:00
Make handling of None values in forms clearer
If the browser posts the value of `<input value='None'>` to the server it does so as a string. We want to post a value of `None` (actually JSON `null`) to the API. To do this we: - set the value in the form class to `'None'` (ie a string) - convert to `None` (as a type) afterwards However seeing `x = 'None'` in code looks a bit like a mistake. So to make sure it looks deliberate and clear what is happening this commit: - makes a reusable constant for `'None'` - adds a comment explaining why it’s a string
This commit is contained in:
@@ -813,9 +813,8 @@ def service_preview_email_branding(service_id):
|
||||
form = ServicePreviewBranding(branding_style=branding_style)
|
||||
|
||||
if form.validate_on_submit():
|
||||
branding_style = None if form.branding_style.data == 'None' else form.branding_style.data
|
||||
current_service.update(
|
||||
email_branding=branding_style
|
||||
email_branding=form.branding_style.data
|
||||
)
|
||||
return redirect(url_for('.service_settings', service_id=service_id))
|
||||
|
||||
|
||||
Reference in New Issue
Block a user