def view_notification(request, notification_id): """ get the notification depending on nid. Display it. """ user = request.user newest, newer, notification, older, oldest = get_notification( notification_id, user) if not notification: raise http.Http404 notification.is_read = True notification.save() context = { 'user': user, 'notification': notification, 'newest': newest, 'newer': newer, 'older': older, 'oldest': oldest, } return shortcuts.render_to_response('profile/view_notification.html', RequestContext(request, context))
def view_notification(request, notification_id): """ get the notification depending on nid. Display it. """ user = request.user newest, newer, notification, older, oldest = get_notification( notification_id, user) if not notification: raise http.Http404 notification.is_read = True notification.save() context = {'user':user, 'notification':notification, 'newest':newest, 'newer':newer, 'older':older, 'oldest':oldest, } return shortcuts.render_to_response( 'profile/view_notification.html', RequestContext(request, context))
def delete_notification(request, notification_id): """ check if the user owns the notification and delete it. """ user = request.user newest, newer, notification, older, oldest = get_notification(notification_id, user) if not notification: raise http.Http404 notification.is_deleted = True notification.save() if older: redirect_url = reverse("view_notification", kwargs={"notification_id": older.id}) else: redirect_url = reverse("browse_notifications") return shortcuts.redirect(redirect_url)
def unread_notification(request, notification_id): """ check if the user owns the notification and delete it. """ user = request.user newest, newer, notification, older, oldest = get_notification( notification_id, user) if not notification: raise http.Http404 notification.is_read = False notification.save() if older: redirect_url = reverse('view_notification', kwargs={'notification_id': older.id}) else: redirect_url = reverse('browse_notifications') return shortcuts.redirect(redirect_url)