added browse_notifications functionality .
authornishanth
Thu, 25 Feb 2010 19:39:02 +0530
changeset 101 e2903a92b5e8
parent 100 2275886511df
child 102 67de265ca06a
added browse_notifications functionality .
taskapp/views/user.py
templates/user/browse_notifications.html
urls.py
--- a/taskapp/views/user.py	Thu Feb 25 18:49:17 2010 +0530
+++ b/taskapp/views/user.py	Thu Feb 25 19:39:02 2010 +0530
@@ -153,3 +153,21 @@
         return show_msg("Your reply has been processed", browse_request_url, "view other requests")
     else:
         return show_msg("You are not authorised to do this", browse_request_url, "view other requests")
+
+@login_required
+def browse_notifications(request):
+    """ get the list of notifications that are not deleted and display in datetime order.
+    """
+
+    user = request.user
+
+    active_notifications = user.notification_to.filter(deleted=False).order_by('sent_date').reverse()
+    for pos, notification in enumerate(reversed(active_notifications)):
+        notification.pos = pos
+
+    context = {
+        'user':user,
+        'notifications':active_notifications,
+    }
+
+    return render_to_response('user/browse_notifications.html', context)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/templates/user/browse_notifications.html	Thu Feb 25 19:39:02 2010 +0530
@@ -0,0 +1,9 @@
+{% extends 'base.html' %}
+{% block content %}
+    {% for notification in notifications %}
+        <a href="/user/notifications/nid={{notification.pos}}">
+        {% if not notification.is_read %} <b> {% endif %}
+        {{notification.sub}}
+        {% if not notification.is_read %} </b> {% endif %}</a><br />
+    {% endfor %}
+{% endblock %}
--- a/urls.py	Thu Feb 25 18:49:17 2010 +0530
+++ b/urls.py	Thu Feb 25 19:39:02 2010 +0530
@@ -48,5 +48,7 @@
     (r'^user/requests/$', userViews.browse_requests),
     (r'^user/requests/rid=(\d+)/$', userViews.view_request),
     (r'^user/requests/rid=(\d+)/(\w+)/$', userViews.process_request),
+
+    (r'^user/notifications/$', userViews.browse_notifications),
     
 )