profile/views.py
changeset 282 69d1c4b99503
parent 276 c8c47fcb46f0
child 287 d24b4a7147d2
equal deleted inserted replaced
281:20f411241654 282:69d1c4b99503
     1 from django.shortcuts import render_to_response, redirect
     1 from django.shortcuts import render_to_response, redirect
       
     2 from django.http import Http404
     2 
     3 
     3 from django.contrib.auth.decorators import login_required
     4 from django.contrib.auth.decorators import login_required
     4 from django.core.context_processors import csrf
     5 from django.core.context_processors import csrf
     5 from django.views.decorators.csrf import csrf_protect
     6 from django.views.decorators.csrf import csrf_protect
     6 
     7 
     7 from pytask.profile.forms import EditProfileForm
     8 from pytask.profile.forms import EditProfileForm
       
     9 from pytask.profile.utils import get_notification
     8 
    10 
     9 @login_required
    11 @login_required
    10 def view_profile(request):
    12 def view_profile(request):
    11 
    13 
    12     user = request.user
    14     user = request.user
    54 
    56 
    55     context = {'user':user,
    57     context = {'user':user,
    56                'notifications':active_notifications,
    58                'notifications':active_notifications,
    57               }                               
    59               }                               
    58 
    60 
       
    61     print active_notifications
       
    62 
    59     return render_to_response('profile/browse_notifications.html', context)
    63     return render_to_response('profile/browse_notifications.html', context)
    60 
    64 
    61 @login_required
    65 @login_required
    62 def view_notification(request, nid):
    66 def view_notification(request, nid):
    63     """ get the notification depending on nid.
    67     """ get the notification depending on nid.
    64     Display it.
    68     Display it.
    65     """
    69     """
    66 
    70 
    67     user = get_user(request.user)
    71     user = request.user
    68     newest, newer, notification, older, oldest =
    72     newest, newer, notification, older, oldest = get_notification(nid, user)
    69     get_notification(nid, user)
       
    70 
    73 
    71     if not notification:
    74     if not notification:
    72         raise Http404
    75         raise Http404
    73 
    76 
    74     notification.is_read = True
    77     notification.is_read = True