Commit 4a39e225 authored by frekk's avatar frekk

add username and groups widget

parent 306803c3
......@@ -39,6 +39,12 @@ class MemberMiddleware:
request.member.token = None
request.member.save()
if request.user.ldap_user is not None:
# copy the LDAP groups so templates can access them
request.member.groups = list(request.user.ldap_user.group_names)
else:
request.member.groups = [ "gumby" ]
# request.session is a dictionary-like object, its content is saved in the database
# and only a session ID is stored as a browser cookie (by default, but is configurable)
if 'member_id' in request.session:
......
......@@ -105,7 +105,7 @@ nav {
overflow: auto; /* make navbar expand in case the tab buttons flow to a second row */
}
.navtab {
.navtab, .userinfo {
float: left;
text-decoration: none;
color: white;
......@@ -131,6 +131,47 @@ nav {
border-right: 1.5px solid #555;
}
.userinfo {
float: right;
border-right: 0;
margin-right: 0;
font-variant-caps: normal;
border: none;
background-color: none;
padding: 19px 20px;
}
.userinfo.groups {
padding: 7px 20px;
}
.userinfo .username {
display: block;
line-height: 22px;
font-size: 16px;
font-weight: 600;
}
/* height of group tags comes to 22px */
.userinfo .group {
display: inline-block;
border-radius: 11px;
font-size: 12px;
line-height: 14px;
padding: 5px 8px 3px 8px;
background-color: #f6b9d8;
color: #000;
margin: 0 4px;
}
.userinfo .group.door {
background-color: #b9c6f6;
}
.userinfo .group.wheel {
background-color: #b9f6c8;
}
.member-details, .membership-details {
width: 100%;
text-align: left;
......
......@@ -50,6 +50,17 @@
<a class="navtab {% if url_name == 'logout' %}active{% endif %}" href="{% url "memberdb:logout" %}">Logout</a>
{% endif %}
{% endwith %}
{# add the groups class only if we have groups to display #}
<div class="userinfo{% if request.user.is_authenticated %}{% if request.member %} groups{% endif %}">
<span class="username">Welcome, {{ request.user.username }}</span>
{% if request.member %}
{% for g in request.member.groups %}<span class="group {{ g }}">{{ g }}</span>{% endfor %}
{% endif %}
{% else %}">
<span class="username">Not logged in</span>
{% endif %}
</div>
</nav>
{% endblock %}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment