Commit 4fa2b76f authored by Chris Reffett's avatar Chris Reffett
Browse files

Restrict navbar so that only approved users may see the administration dropdown

parent d8325ae7
{% load go_extras %}
<div class="navbar navbar-default">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-responsive-collapse">
......@@ -12,7 +13,7 @@
<li><a href="{% url 'about' %}">About</a></li>
{% if user.is_authenticated %}
<li><a href="{% url 'my_links' %}">My Links</a></li>
{% if user.is_staff %}
{% if user.is_staff and user|is_approved %}
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown">Administration<b class="caret"></b></a>
<ul class="dropdown-menu">
......@@ -21,6 +22,9 @@
</ul>
</li>
{% endif %}
{% if not user|is_registered %}
<li><a href="{% url 'signup' %}">Register</a></li>
{% endif %}
<li><a href="{% url 'go_logout' %}">Log Out</a></li>
{% else %}
<li><a href="{% url 'go_login' %}">Log In</a></li>
......
......@@ -9,3 +9,11 @@ def is_registered( user ):
return True
except RegisteredUser.DoesNotExist:
return False
@register.filter
def is_approved(user):
try:
registered = RegisteredUser.objects.get( username=user.username )
return registered.approved
except RegisteredUser.DoesNotExist:
return False
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