diff --git a/app.py b/app.py index f6be5c8..2c779bc 100644 --- a/app.py +++ b/app.py @@ -27,6 +27,12 @@ logger = logging.getLogger('gandalf.web') app = Flask(__name__) +_AVATAR_COLORS = ['lt-avatar--orange', 'lt-avatar--green', 'lt-avatar--purple', ''] + +@app.template_filter('avatar_color') +def avatar_color_filter(name: str) -> str: + return _AVATAR_COLORS[abs(hash(name)) % len(_AVATAR_COLORS)] + _cfg = None diff --git a/templates/base.html b/templates/base.html index 3fd40b5..e0884a1 100644 --- a/templates/base.html +++ b/templates/base.html @@ -42,9 +42,11 @@ Inspector + {% if user.groups and 'admin' in user.groups %} Suppressions + {% endif %}
@@ -93,20 +95,49 @@ {% if request.endpoint == 'inspector' %}aria-current="page"{% endif %}> Inspector + {% if user.groups and 'admin' in user.groups %} +
+ + +
+ {% else %} Suppressions + {% endif %}
{% set _uname = user.name or user.username %} -
{{ _uname[0] | upper }}
+ {% set _words = _uname.split() %} + {% set _initials = (_words[0][0] ~ (_words[1][0] if _words|length > 1 else ''))|upper %} + {{ _uname }} {% if user.groups and 'admin' in user.groups %} - admin + ADMIN {% endif %}