blob: 386ca49f3a550c9d8b9cc369b7b745892045f3e2 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
|
from django.shortcuts import render_to_response, redirect
from django.contrib.auth.decorators import login_required
from django.core.context_processors import csrf
from django.views.decorators.csrf import csrf_protect
from pytask.profile.forms import EditProfileForm
@login_required
def view_profile(request):
user = request.user
profile = user.get_profile()
context = {"user": user,
"profile": profile,
}
return render_to_response("profile/view.html", context)
@login_required
def edit_profile(request):
user = request.user
profile = user.get_profile()
context = {"user": user,
"profile": profile,
}
context.update(csrf(request))
if request.method == "POST":
form = EditProfileForm(request.POST, instance=profile)
if form.is_valid():
form.save()
return redirect("/accounts/profile/view")
else:
context.update({"form":form})
return render_to_response("profile/edit.html", context)
else:
form = EditProfileForm(instance=profile)
context.update({"form":form})
return render_to_response("profile/edit.html", context)
@login_required
def browse_notifications(request):
""" get the list of notifications that are not deleted and display in
datetime order."""
user = request.user
active_notifications = user.notification_sent_to.filter(is_deleted=False).order_by('sent_date').reverse()
context = {'user':user,
'notifications':active_notifications,
}
return render_to_response('profile/browse_notifications.html', context)
|