From ee9ca4578cda64df058e768de5258426a970b2fb Mon Sep 17 00:00:00 2001 From: Nishanth Amuluru Date: Fri, 7 Jan 2011 15:16:29 +0530 Subject: created a tag and used it in the template --- profile/templatetags/user_tags.py | 12 ++++++++++++ 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 %} +{% load user_tags %}