taskapp/utilities/user.py
changeset 137 e56b95298254
child 143 796ff9e279a8
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/taskapp/utilities/user.py	Sun Feb 28 03:31:40 2010 +0530
@@ -0,0 +1,17 @@
+"""
+A collection of utility functions for user.
+"""
+
+def get_user(user):
+    """ get the no of unread requests and notifications and add them as properties for user.
+    """
+
+    unread_notifications = user.notification_sent_to.filter(is_read=False,is_deleted=False).count
+    unread_requests = user.request_sent_to.filter(is_valid=True,is_replied=False).count
+
+    user.unread_notifications = unread_notifications
+    user.unread_requests = unread_requests
+
+    return user
+
+