Add new filter for rendering FileStorage name in case of invalid financial form submission
This commit is contained in:
@@ -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
|
||||
|
Reference in New Issue
Block a user