Cast empty string value in form_field to None

For FilmProjectForm, when no value is specified we want to save it
as None in the project document.
This commit is contained in:
Francesco Siddi 2019-04-04 13:09:53 +02:00
parent 6d47946b1b
commit b62f500b2e

View File

@ -608,6 +608,9 @@ def save_film_settings(project: pillarsdk.Project):
form_field = getattr(form, field_name)
# TODO(fsiddi) if form_field type is FileSelectField, convert it to ObjectId
# Currently this raises TypeError: Object of type 'ObjectId' is not JSON serializable
if form_field.data == '':
form_field.data = None
updated_extension_props[field_name] = form_field.data
# Update extension props and save project