1
0
Fork 0
mirror of https://codeberg.org/Mo8it/AdvLabDB.git synced 2024-11-08 21:21:06 +00:00

Add missing_formatter

This commit is contained in:
Mo 2022-06-01 23:03:13 +02:00
parent 2da2a67b94
commit 9f055d7a7e

View file

@ -1,6 +1,7 @@
# Functions not dependent on advlabdb
from flask import flash
from markupsafe import Markup
def flashRandomPassword(password):
@ -15,3 +16,11 @@ def parse_bool(str):
return True
else:
raise ValueError(f'Can not parse a bool from "{str}"')
def missing_formatter(view, context, model, name):
attr = getattr(model, name)
if attr is None:
return Markup("<span style='color:red'>MISSING</span>")
return attr