pytask/profile/templatetags/user_tags.py
author Nishanth Amuluru <nishanth@fossee.in>
Wed, 12 Jan 2011 00:22:27 +0530
changeset 149 32dd15eaf9d0
parent 69 c6bca38c1cbf
permissions -rw-r--r--
fixed a bug where guest users were not able to view the page correctly
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
60
696309b5ad59 created a tag and used it in the template
Nishanth Amuluru <nishanth@fossee.in>
parents: 59
diff changeset
     1
from django import template
696309b5ad59 created a tag and used it in the template
Nishanth Amuluru <nishanth@fossee.in>
parents: 59
diff changeset
     2
696309b5ad59 created a tag and used it in the template
Nishanth Amuluru <nishanth@fossee.in>
parents: 59
diff changeset
     3
register = template.Library()
696309b5ad59 created a tag and used it in the template
Nishanth Amuluru <nishanth@fossee.in>
parents: 59
diff changeset
     4
696309b5ad59 created a tag and used it in the template
Nishanth Amuluru <nishanth@fossee.in>
parents: 59
diff changeset
     5
@register.filter
696309b5ad59 created a tag and used it in the template
Nishanth Amuluru <nishanth@fossee.in>
parents: 59
diff changeset
     6
def notf_dsp(user):
696309b5ad59 created a tag and used it in the template
Nishanth Amuluru <nishanth@fossee.in>
parents: 59
diff changeset
     7
696309b5ad59 created a tag and used it in the template
Nishanth Amuluru <nishanth@fossee.in>
parents: 59
diff changeset
     8
    notf_cnt = user.notification_sent_to.filter(is_deleted=False,
696309b5ad59 created a tag and used it in the template
Nishanth Amuluru <nishanth@fossee.in>
parents: 59
diff changeset
     9
                                                is_read=False).count()
696309b5ad59 created a tag and used it in the template
Nishanth Amuluru <nishanth@fossee.in>
parents: 59
diff changeset
    10
696309b5ad59 created a tag and used it in the template
Nishanth Amuluru <nishanth@fossee.in>
parents: 59
diff changeset
    11
    return u'notifications(%s)'%notf_cnt if notf_cnt else u'notifications'
696309b5ad59 created a tag and used it in the template
Nishanth Amuluru <nishanth@fossee.in>
parents: 59
diff changeset
    12