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:
parent
2da2a67b94
commit
9f055d7a7e
1 changed files with 9 additions and 0 deletions
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue