1
0
Fork 0
mirror of https://codeberg.org/Mo8it/AdvLabDB.git synced 2024-12-20 23:41:20 +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 # Functions not dependent on advlabdb
from flask import flash from flask import flash
from markupsafe import Markup
def flashRandomPassword(password): def flashRandomPassword(password):
@ -15,3 +16,11 @@ def parse_bool(str):
return True return True
else: else:
raise ValueError(f'Can not parse a bool from "{str}"') 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