summaryrefslogtreecommitdiff
path: root/taskapp/views/user.py
diff options
context:
space:
mode:
authornishanth2010-02-25 20:13:59 +0530
committernishanth2010-02-25 20:13:59 +0530
commit6126d148bb0569cb185614437369535b43b4ca8e (patch)
tree1f622a7bdd6b0b70840ff7d73459670d493ad0bc /taskapp/views/user.py
parent2fdc3b3fa991a219122d404be058f0102b48ccac (diff)
downloadpytask-6126d148bb0569cb185614437369535b43b4ca8e.tar.gz
pytask-6126d148bb0569cb185614437369535b43b4ca8e.tar.bz2
pytask-6126d148bb0569cb185614437369535b43b4ca8e.zip
added the functionality to view each notification
Diffstat (limited to 'taskapp/views/user.py')
-rw-r--r--taskapp/views/user.py43
1 files changed, 43 insertions, 0 deletions
diff --git a/taskapp/views/user.py b/taskapp/views/user.py
index 5dc686d..e1e3fbd 100644
--- a/taskapp/views/user.py
+++ b/taskapp/views/user.py
@@ -171,3 +171,46 @@ def browse_notifications(request):
}
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")
+