taskapp/utilities/user.py
author anoop
Tue, 09 Mar 2010 11:39:34 +0530
changeset 214 679c7e237052
parent 144 581ad20b8c39
permissions -rw-r--r--
added two more templates for displaying admin login form and admin logout message.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
137
e56b95298254 now requests in sidebar shows the no.of unread notifications.
nishanth
parents:
diff changeset
     1
"""
e56b95298254 now requests in sidebar shows the no.of unread notifications.
nishanth
parents:
diff changeset
     2
A collection of utility functions for user.
e56b95298254 now requests in sidebar shows the no.of unread notifications.
nishanth
parents:
diff changeset
     3
"""
e56b95298254 now requests in sidebar shows the no.of unread notifications.
nishanth
parents:
diff changeset
     4
e56b95298254 now requests in sidebar shows the no.of unread notifications.
nishanth
parents:
diff changeset
     5
def get_user(user):
e56b95298254 now requests in sidebar shows the no.of unread notifications.
nishanth
parents:
diff changeset
     6
    """ get the no of unread requests and notifications and add them as properties for user.
e56b95298254 now requests in sidebar shows the no.of unread notifications.
nishanth
parents:
diff changeset
     7
    """
e56b95298254 now requests in sidebar shows the no.of unread notifications.
nishanth
parents:
diff changeset
     8
143
796ff9e279a8 now if a user accepts to be a mentor, all his pending reqs will be made invalid.
nishanth
parents: 137
diff changeset
     9
    unread_notifications = user.notification_sent_to.filter(is_read=False,is_deleted=False)
144
581ad20b8c39 modified get_user method to give only count of unread requests.
nishanth
parents: 143
diff changeset
    10
    unread_requests = user.request_sent_to.filter(is_valid=True,is_replied=False,is_read=False)
137
e56b95298254 now requests in sidebar shows the no.of unread notifications.
nishanth
parents:
diff changeset
    11
e56b95298254 now requests in sidebar shows the no.of unread notifications.
nishanth
parents:
diff changeset
    12
    user.unread_notifications = unread_notifications
e56b95298254 now requests in sidebar shows the no.of unread notifications.
nishanth
parents:
diff changeset
    13
    user.unread_requests = unread_requests
e56b95298254 now requests in sidebar shows the no.of unread notifications.
nishanth
parents:
diff changeset
    14
e56b95298254 now requests in sidebar shows the no.of unread notifications.
nishanth
parents:
diff changeset
    15
    return user
e56b95298254 now requests in sidebar shows the no.of unread notifications.
nishanth
parents:
diff changeset
    16
e56b95298254 now requests in sidebar shows the no.of unread notifications.
nishanth
parents:
diff changeset
    17