2022-05-16 20:20:36 +00:00
|
|
|
# Functions not dependent on advlabdb
|
|
|
|
|
|
|
|
from flask import flash
|
2022-06-01 21:03:13 +00:00
|
|
|
from markupsafe import Markup
|
2022-05-16 20:20:36 +00:00
|
|
|
|
|
|
|
|
|
|
|
def flashRandomPassword(password):
|
|
|
|
flash(f"Random password: {password}", category="warning")
|
|
|
|
|
2022-04-18 16:04:17 +00:00
|
|
|
|
|
|
|
def parse_bool(str):
|
|
|
|
str_lower = str.lower()
|
|
|
|
if str_lower == "false":
|
|
|
|
return False
|
|
|
|
elif str_lower == "true":
|
|
|
|
return True
|
|
|
|
else:
|
2022-05-09 00:10:30 +00:00
|
|
|
raise ValueError(f'Can not parse a bool from "{str}"')
|
2022-06-01 21:03:13 +00:00
|
|
|
|
|
|
|
|
|
|
|
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
|