diff options
author | Nishanth Amuluru | 2011-01-07 12:35:18 +0530 |
---|---|---|
committer | Nishanth Amuluru | 2011-01-07 12:35:18 +0530 |
commit | ba598cf99d39a132fab441db176484876be0ecc5 (patch) | |
tree | dfbef41aed5162862988b74ce51203f41e79de1c | |
parent | 75d1a5e6a46ded6293b730b57b2a89484a96dd6d (diff) | |
download | pytask-ba598cf99d39a132fab441db176484876be0ecc5.tar.gz pytask-ba598cf99d39a132fab441db176484876be0ecc5.tar.bz2 pytask-ba598cf99d39a132fab441db176484876be0ecc5.zip |
created a view for view notification and included the url. made changes accordingly in browse notifications
-rw-r--r-- | profile/urls.py | 3 | ||||
-rwxr-xr-x | profile/views.py | 26 | ||||
-rw-r--r-- | templates/profile/browse_notifications.html | 2 |
3 files changed, 29 insertions, 2 deletions
diff --git a/profile/urls.py b/profile/urls.py index a5e92cd..4046fa5 100644 --- a/profile/urls.py +++ b/profile/urls.py @@ -1,12 +1,13 @@ from django.conf.urls.defaults import * from pytask.profile.views import view_profile, edit_profile,\ - browse_notifications + browse_notifications, view_notification urlpatterns = patterns('', (r'^view/$', view_profile), (r'^edit/$', edit_profile), (r'^notf/browse/$', browse_notifications), + (r'^notf/view/nid=(\w+)$', view_notification), ) diff --git a/profile/views.py b/profile/views.py index 386ca49..40eb0a7 100755 --- a/profile/views.py +++ b/profile/views.py @@ -57,3 +57,29 @@ def browse_notifications(request): } return render_to_response('profile/browse_notifications.html', context) + +@login_required +def view_notification(request, nid): + """ get the notification depending on nid. + Display it. + """ + + user = get_user(request.user) + newest, newer, notification, older, oldest = + get_notification(nid, user) + + if not notification: + raise Http404 + + notification.is_read = True + notification.save() + + context = {'user':user, + 'notification':notification, + 'newest':newest, + 'newer':newer, + 'older':older, + 'oldest':oldest, + } + + return render_to_response('profile/view_notification.html', context) diff --git a/templates/profile/browse_notifications.html b/templates/profile/browse_notifications.html index 8f53278..9638a35 100644 --- a/templates/profile/browse_notifications.html +++ b/templates/profile/browse_notifications.html @@ -5,7 +5,7 @@ You have no notifications. {% else %} Notifications for you: <br /> {% for notification in notifications %} -<a href="/user/notifications/nid={{notification.uniq_key}}"> +<a href="/profile/notf/view/nid={{notification.uniq_key}}"> {% if not notification.is_read %} <b> {% endif %} {{notification.sub}} {% if not notification.is_read %} </b> {% endif %}</a><br /> |