Update mixedContentToJson filter to be more general

This commit is contained in:
Patrick Smith 2019-01-21 15:52:56 -05:00
parent 37f8f41be9
commit 4a377007f6

View File

@ -54,12 +54,11 @@ def mixedContentToJson(value):
This coerces the file upload in form data to its filename This coerces the file upload in form data to its filename
so that the data can be JSON serialized. so that the data can be JSON serialized.
""" """
if ( if isinstance(value, dict):
isinstance(value, dict) for k, v in value.items():
and "legacy_task_order" in value if hasattr(v, "filename"):
and hasattr(value["legacy_task_order"]["pdf"], "filename") value[k] = v.filename
):
value["legacy_task_order"]["pdf"] = value["legacy_task_order"]["pdf"].filename
return app.jinja_env.filters["tojson"](value) return app.jinja_env.filters["tojson"](value)