Permalink
Browse files

Merge pull request #152 from glogiotatidis/740877-top-nav-does

Add state to top navigation menu. Fix bug 740877.
  • Loading branch information...
2 parents 7d3c2de + 9d227b8 commit 602980d8911e667e367ee077ab7d5cf9b650caa8 @glogiotatidis glogiotatidis committed May 2, 2012
View
@@ -230,6 +230,10 @@ li.last {
border-right:none;
}
+.active-nav {
+ font-weight: bold;
+}
+
/* -----------------------------------------
Main Page Styles
----------------------------------------- */
View
@@ -1,7 +1,6 @@
from functools import wraps
from django.contrib import messages
-from django.core.urlresolvers import reverse
from django.shortcuts import redirect
View
@@ -1,5 +1,6 @@
import base64
import binascii
+import re
import time
from django.conf import settings
@@ -113,4 +114,14 @@ def mailhide(value):
@register.filter
def get_bugzilla_url(bug_id):
+ """Return bugzilla url for bug_id."""
return u'https://bugzilla.mozilla.org/show_bug.cgi?id=%d' % bug_id
+
+
+@register.function
+def active(request, pattern):
+ """Return 'active-nav' string when pattern matches request's full path."""
+ if re.match(pattern, request.get_full_path()):
+ return 'active-nav'
+
+ return None
View
@@ -3,8 +3,10 @@
from django.db import models
from south.modelsinspector import add_introspection_rules
+
class UTCDateTimeField(models.DateTimeField):
"""A django DateTimeField that uses utcnow() instead of now()."""
+
def pre_save(self, model_instance, add):
if self.auto_now or (self.auto_now_add and add):
value = datetime.datetime.utcnow()
@@ -13,5 +15,6 @@ def pre_save(self, model_instance, add):
else:
return super(UTCDateTimeField, self).pre_save(model_instance, add)
+
# Add South Introspection Rules for UTCDateTimeField.
add_introspection_rules([], ["^remo\.base\.models\.UTCDateTimeField"])
@@ -108,13 +108,16 @@
<ul class="nav-bar">
<li>
{% if user.is_authenticated() %}
- <a href="{{ url('dashboard') }}" class="main">Dashboard</a>
+ <a href="{{ url('dashboard') }}"
+ class="main {{ active(request, '^/dashboard') }}">Dashboard</a>
{% else %}
- <a href="{{ url('main') }}" class="main">Main</a>
+ <a href="{{ url('main') }}"
+ class="main {{ active(request, '^/$') }}">Main</a>
{% endif %}
</li>
<li>
- <a href="{{ url('profiles_list_profiles') }}" class="main">People</a>
+ <a href="{{ url('profiles_list_profiles') }}"
+ class="main {{ active(request, '^/people/') }}">People</a>
</li>
<li>
<a href="https://wiki.mozilla.org/ReMo/Events" class="main">Events</a>
@@ -129,7 +132,8 @@
<a href="https://wiki.mozilla.org/ReMo" class="main">Wiki</a>
</li>
<li class="last">
- <a href="{{ url('faq') }}" class="main">FAQ</a>
+ <a href="{{ url('faq') }}"
+ class="main {{ active(request, '^/faq/$') }}">FAQ</a>
</li>
</ul>
</div>
@@ -138,10 +142,17 @@
<div class="eight columns show-on-phones" id="navigation-box-mobile">
<ul class="nav-bar">
<li>
- <a href="{{ url('main') }}" class="main">Main</a>
+ {% if user.is_authenticated() %}
+ <a href="{{ url('dashboard') }}"
+ class="main {{ active(request, '^/dashboard') }}">Dashboard</a>
+ {% else %}
+ <a href="{{ url('main') }}"
+ class="main {{ active(request, '^/$') }}">Main</a>
+ {% endif %}
</li>
<li>
- <a href="{{ url('profiles_list_profiles') }}" class="main">People</a>
+ <a href="{{ url('profiles_list_profiles') }}"
+ class="main {{ active(request, '^/people/') }}">People</a>
</li>
<li>
<a href="https://wiki.mozilla.org/ReMo/Events" class="main">Events</a>
View
@@ -4,7 +4,6 @@
from django.conf import settings
from django.contrib import messages
from django.contrib.auth.models import User
-from django.core.urlresolvers import reverse
from django.db.models import Q
from django.shortcuts import redirect, render
from django.template import Context, RequestContext, loader
@@ -3,6 +3,7 @@
from remo.base.models import UTCDateTimeField
+
class FeaturedRep(models.Model):
"""Featured Rep model.
View
@@ -5,6 +5,7 @@
from remo.base.models import UTCDateTimeField
+
class Bug(models.Model):
"""Bug model definition."""
created_on = UTCDateTimeField(auto_now_add=True)

0 comments on commit 602980d

Please sign in to comment.