Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
UCC
uccportal
Commits
4a39e225
Commit
4a39e225
authored
Apr 23, 2019
by
frekk
Browse files
add username and groups widget
parent
306803c3
Changes
3
Hide whitespace changes
Inline
Side-by-side
src/memberdb/views.py
View file @
4a39e225
...
...
@@ -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
:
...
...
src/static/memberdb.css
View file @
4a39e225
...
...
@@ -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
;
...
...
src/templates/base.html
View file @
4a39e225
...
...
@@ -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 %}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment