Add new filter for rendering FileStorage name in case of invalid financial form submission

This commit is contained in:
Montana
2018-08-27 14:22:44 -04:00
parent 6df897191c
commit be080ed205
4 changed files with 30 additions and 1 deletions

View File

@@ -1,4 +1,6 @@
import re
from flask import current_app as app
from werkzeug.datastructures import FileStorage
def iconSvg(name):
@@ -31,9 +33,20 @@ def getOptionLabel(value, options):
return next(tup[1] for tup in options if tup[0] == value)
def enhancedToJson(value):
if (
isinstance(value, dict)
and "task_order" in value
and isinstance(value["task_order"], FileStorage)
):
value["task_order"] = value["task_order"].filename
return app.jinja_env.filters["tojson"](value)
def register_filters(app):
app.jinja_env.filters["iconSvg"] = iconSvg
app.jinja_env.filters["dollars"] = dollars
app.jinja_env.filters["usPhone"] = usPhone
app.jinja_env.filters["readableInteger"] = readableInteger
app.jinja_env.filters["getOptionLabel"] = getOptionLabel
app.jinja_env.filters["enhancedToJson"] = enhancedToJson