diff options
author | Nishanth Amuluru | 2011-01-07 15:16:29 +0530 |
---|---|---|
committer | Nishanth Amuluru | 2011-01-07 15:16:29 +0530 |
commit | ee9ca4578cda64df058e768de5258426a970b2fb (patch) | |
tree | 9cb2c064d49052cf1c0464a992c63841869ee451 | |
parent | 31fce84c23ca5cf2c7a656143bfa851de34a6e64 (diff) | |
download | pytask-ee9ca4578cda64df058e768de5258426a970b2fb.tar.gz pytask-ee9ca4578cda64df058e768de5258426a970b2fb.tar.bz2 pytask-ee9ca4578cda64df058e768de5258426a970b2fb.zip |
created a tag and used it in the template
-rw-r--r-- | profile/templatetags/user_tags.py | 12 | ||||
-rw-r--r-- | templates/base.html | 16 |
2 files changed, 15 insertions, 13 deletions
diff --git a/profile/templatetags/user_tags.py b/profile/templatetags/user_tags.py index e69de29..e03aa09 100644 --- a/profile/templatetags/user_tags.py +++ b/profile/templatetags/user_tags.py @@ -0,0 +1,12 @@ +from django import template + +register = template.Library() + +@register.filter +def notf_dsp(user): + + notf_cnt = user.notification_sent_to.filter(is_deleted=False, + is_read=False).count() + + return u'notifications(%s)'%notf_cnt if notf_cnt else u'notifications' + diff --git a/templates/base.html b/templates/base.html index 133d6e3..94d024a 100644 --- a/templates/base.html +++ b/templates/base.html @@ -4,6 +4,7 @@ {% block js_script %} {% endblock %} <link rel=stylesheet href="/static/css/base.css" type="text/css" > </head> +{% load user_tags %} <body> <div id="wrapper"> <div id="header"> @@ -17,19 +18,8 @@ <li><a href="/task/browse/" title="tasks">tasks</a></li> <li><a href="/textbook/" title="textbook">textbooks</a></li> <br /> - <li><a href="/user/notifications/" title="notifications"> - {% if user.unread_notifications.count %} - notifications({{user.unread_notifications.count}}) - {% else %} - notifications - {% endif %} - </a></li> - <li><a href="/user/requests/" title="Requests"> - {% if user.unread_requests.count %} - requests({{user.unread_requests.count}}) - {% else %} - requests - {% endif %} + <li><a href="/profile/notf/browse/" title="notifications"> + {{ user|notf_dsp }} </a></li> <br> <li><a href="/profile/view">profile</a></li> |