diff --git a/hsman/app/filters.py b/hsman/app/filters.py index bfd5497..662a932 100644 --- a/hsman/app/filters.py +++ b/hsman/app/filters.py @@ -7,49 +7,51 @@ import logging log = logging.getLogger(__name__) -def htime(ts): - if ts: - dt = datetime.datetime.fromtimestamp(ts) +def htime(timestamp): + if timestamp: + dt = datetime.datetime.fromtimestamp(timestamp) return humanize.naturaltime(dt) -def htime_dt(dt): - if dt: +def htime_dt(datetime): + if datetime: try: - return humanize.naturaltime(dt) + return humanize.naturaltime(datetime) except ValueError: return "Never" + return "Never" -def hdate(ts): - if ts: - dt = datetime.datetime.fromtimestamp(ts) +def hdate(timestamp): + if timestamp: + dt = datetime.datetime.fromtimestamp(timestamp) return humanize.naturaldate(dt) -def hdate_dt(dt): - if dt: +def hdate_dt(datetime): + if datetime: try: - return humanize.naturaldate(dt) + return humanize.naturaldate(datetime) except ValueError: return "Never" + return "Never" -def fmt_timestamp(ts): +def fmt_timestamp(timestamp): with current_app.app_context(): tz = ZoneInfo(current_app.config['APP_TZ']) - if ts: - local_ts = datetime.datetime.fromtimestamp(ts, tz) + if timestamp: + local_ts = datetime.datetime.fromtimestamp(timestamp, tz) return "%s %s" % (local_ts.strftime('%Y-%m-%d %H:%M:%S'), local_ts.tzname()) -def fmt_datetime(dt): +def fmt_datetime(datetime): with current_app.app_context(): tz = ZoneInfo(current_app.config['APP_TZ']) - if dt: + if datetime: try: - local_ts = dt.fromtimestamp(dt.timestamp(), tz) + local_ts = datetime.fromtimestamp(datetime.timestamp(), tz) except OverflowError: return "Never" return "%s %s" % (local_ts.strftime('%Y-%m-%d %H:%M:%S'), diff --git a/hsman/app/lib.py b/hsman/app/lib.py index 3f0439f..744dc07 100644 --- a/hsman/app/lib.py +++ b/hsman/app/lib.py @@ -20,6 +20,13 @@ def remote_ip() -> str: return str(request.environ.get('REMOTE_ADDR')) +def username() -> str: + userinfo = flask_session['userinfo'] + if 'preferred_username' in userinfo: + return userinfo['preferred_username'] + return userinfo['email'] + + def webMode() -> bool: is_gunicorn = "gunicorn" in os.environ.get('SERVER_SOFTWARE', '') is_werkzeug = os.environ.get('WERKZEUG_RUN_MAIN', False) == "true" diff --git a/hsman/app/static/main.css b/hsman/app/static/main.css index aacc4f6..ffed578 100644 --- a/hsman/app/static/main.css +++ b/hsman/app/static/main.css @@ -103,3 +103,10 @@ div.dt-container div.dt-scroll-body { tr.pka-hide { visibility: collapse; } + +i.disabled { + color: #888; +} +span.expired { + color: #888; +} diff --git a/hsman/app/templates/_macros.html.j2 b/hsman/app/templates/_macros.html.j2 index 7a75b32..240c816 100644 --- a/hsman/app/templates/_macros.html.j2 +++ b/hsman/app/templates/_macros.html.j2 @@ -16,9 +16,3 @@ {% endif %} {% endmacro %} - -{% macro body_theme(theme) -%} -{% if theme == "dark" %} -bootstrap-dark -{% endif %} -{%- endmacro -%} diff --git a/hsman/app/templates/base.html b/hsman/app/templates/base.html index 7ba2288..adb530b 100644 --- a/hsman/app/templates/base.html +++ b/hsman/app/templates/base.html @@ -34,7 +34,6 @@ -