From 515dcfae7247c5d14efebe6f09c5ab9dc61e58ab Mon Sep 17 00:00:00 2001 From: nishanth Date: Sun, 28 Feb 2010 03:31:40 +0530 Subject: now requests in sidebar shows the no.of unread notifications. --- taskapp/utilities/user.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 taskapp/utilities/user.py (limited to 'taskapp/utilities/user.py') diff --git a/taskapp/utilities/user.py b/taskapp/utilities/user.py new file mode 100644 index 0000000..bafac0b --- /dev/null +++ b/taskapp/utilities/user.py @@ -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 + + -- cgit