Navbar improvements
This commit is contained in:
parent
66ca8ccde5
commit
aee0eded8e
|
@ -1,3 +1,6 @@
|
|||
from .models import User
|
||||
|
||||
|
||||
def user_is_staff(request):
|
||||
return {
|
||||
'USER_IS_STAFF': request.user.is_staff
|
||||
|
@ -10,3 +13,10 @@ def user_configuration(request):
|
|||
'show_admin_links': False
|
||||
}
|
||||
}
|
||||
|
||||
def auth(request):
|
||||
result = {}
|
||||
if request.user.is_authenticated:
|
||||
result['user'] = User.objects.get(pk=request.user.pk)
|
||||
|
||||
return result
|
||||
|
|
|
@ -79,6 +79,7 @@ TEMPLATE_CONTEXT_PROCESSORS = (
|
|||
'shelfzilla.apps.pjax.context_processors.pjax',
|
||||
'shelfzilla.apps.manga.context_processors.user_have_volumes',
|
||||
'shelfzilla.apps.manga.context_processors.user_wishlisted_volumes',
|
||||
'shelfzilla.apps.users.context_processors.auth',
|
||||
'shelfzilla.apps.users.context_processors.user_is_staff',
|
||||
'shelfzilla.apps.users.context_processors.user_configuration',
|
||||
)
|
||||
|
|
|
@ -72,6 +72,10 @@
|
|||
color: #fff;
|
||||
background-color: #000;
|
||||
}
|
||||
|
||||
.avatar {
|
||||
width: 22px;
|
||||
}
|
||||
}
|
||||
|
||||
.alert-error {
|
||||
|
|
|
@ -39,21 +39,22 @@
|
|||
{% endif %}
|
||||
<ul class="nav navbar-nav navbar-right">
|
||||
{% if user.is_authenticated %}
|
||||
<li class="dropdown">
|
||||
<a href="#" class="dropdown-toggle" data-toggle="dropdown">{{ user.username }} <b class="caret"></b></a>
|
||||
<ul class="dropdown-menu">
|
||||
<li><a href="{% url 'profile' %}" title="{% trans "Profile" %}">
|
||||
<img src="{{ user.avatar }}" class="avatar img-rounded"/>
|
||||
{{ user.username }}</a>
|
||||
</li>
|
||||
{% if user.is_superuser %}
|
||||
<li><a data-pjax-unnav href="/admin/">Admin</a></li>
|
||||
<li><a data-pjax-unnav href="/admin/" title="Admin"><i class="glyphicon glyphicon-tower"></i></a></li>
|
||||
{% endif %}
|
||||
<li><a data-pjax-unnav href="{% url 'profile' %}" data-pjax>{% trans "Profile" %}</a></li>
|
||||
<!--
|
||||
<li class="divider"></li>
|
||||
<li><a data-pjax-unnav href="#">{% trans "My collection" %}</a></li>
|
||||
<li><a data-pjax-unnav href="#">{% trans "My wishlist" %}</a></li>
|
||||
-->
|
||||
<li class="divider"></li>
|
||||
<li><a data-pjax-unnav href="{% url "logout" %}">{% trans "Logout" %}</a></li>
|
||||
</ul>
|
||||
<li><a data-pjax-unnav href="{% url 'profile' %}" data-pjax
|
||||
title="{% trans "Profile" %}">
|
||||
<i class="glyphicon glyphicon-user"></i>
|
||||
</a>
|
||||
</li>
|
||||
<li><a data-pjax-unnav href="{% url "logout" %}"
|
||||
title="{% trans "Logout" %}">
|
||||
<i class="glyphicon glyphicon-off"></i>
|
||||
</a>
|
||||
</li>
|
||||
{% else %}
|
||||
<li>
|
||||
|
|
Reference in New Issue