From a3b252cc9dff4c51d784da17c3077d1e09b4134c Mon Sep 17 00:00:00 2001
From: nishanth
Date: Thu, 25 Feb 2010 19:39:02 +0530
Subject: added browse_notifications functionality .
---
taskapp/views/user.py | 18 ++++++++++++++++++
templates/user/browse_notifications.html | 9 +++++++++
urls.py | 2 ++
3 files changed, 29 insertions(+)
create mode 100644 templates/user/browse_notifications.html
diff --git a/taskapp/views/user.py b/taskapp/views/user.py
index fc431cb..5dc686d 100644
--- a/taskapp/views/user.py
+++ b/taskapp/views/user.py
@@ -153,3 +153,21 @@ def process_request(request, rid, reply):
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)
diff --git a/templates/user/browse_notifications.html b/templates/user/browse_notifications.html
new file mode 100644
index 0000000..c4b538e
--- /dev/null
+++ b/templates/user/browse_notifications.html
@@ -0,0 +1,9 @@
+{% extends 'base.html' %}
+{% block content %}
+ {% for notification in notifications %}
+
+ {% if not notification.is_read %} {% endif %}
+ {{notification.sub}}
+ {% if not notification.is_read %} {% endif %}
+ {% endfor %}
+{% endblock %}
diff --git a/urls.py b/urls.py
index 24b944a..2a417ad 100644
--- a/urls.py
+++ b/urls.py
@@ -48,5 +48,7 @@ urlpatterns = patterns('',
(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),
)
--
cgit