# HG changeset patch
# User nishanth
# Date 1267109039 -19800
# Node ID 3a4c8fccb9f3a993ac62ad06a208b5d27e46d172
# Parent 67de265ca06a4d6e3005b9b1585b9c0e26f752fd
added the functionality to view each notification
diff -r 67de265ca06a -r 3a4c8fccb9f3 taskapp/views/user.py
--- a/taskapp/views/user.py Thu Feb 25 19:46:19 2010 +0530
+++ b/taskapp/views/user.py Thu Feb 25 20:13:59 2010 +0530
@@ -171,3 +171,46 @@
}
return render_to_response('user/browse_notifications.html', context)
+
+@login_required
+def view_notification(request, nid):
+ """ get the notification depending on nid.
+ Display it.
+ """
+
+ user = request.user
+ notifications = user.notification_to.filter(deleted=False).order_by('sent_date')
+ notification = notifications[int(nid)]
+ notification.is_read = True
+ notification.save()
+
+ context = {
+ 'user':user,
+ 'notification':notification,
+ }
+
+ return render_to_response('user/view_notification.html', context)
+
+@login_required
+def edit_notification(request, nid, action):
+ """ if action is delete, set is_deleted.
+ if it is unread, unset is_read.
+ save the notification and redirect to browse_notifications.
+ """
+
+ user = request.user
+ notifications = user.notification_to.filter(deleted=False).order_by('sent_date')
+ notification = notifications[int(nid)]
+ notifications_url = "/user/notifications/"
+
+ if request.method == "POST":
+ if action == "delete":
+ notification.deleted = True
+ elif action == "unread":
+ notification.is_read = False
+
+ notification.save()
+ return redirect(notifications_url)
+ else:
+ return show_msg('This is wrong', notification_url, "view the notification")
+
diff -r 67de265ca06a -r 3a4c8fccb9f3 templates/user/view_notification.html
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/templates/user/view_notification.html Thu Feb 25 20:13:59 2010 +0530
@@ -0,0 +1,10 @@
+{% extends 'base.html' %}
+{% block content %}
+ Subject: {{notification.sub}}
+ Sent time: {{notification.sent_date}}
+ {% autoescape off %}
+ {{notification.message}}
+ {% endautoescape %}
+