equal
deleted
inserted
replaced
1 from django.contrib.auth.decorators import login_required |
1 from django.contrib.auth.decorators import login_required |
2 from django.core.context_processors import csrf |
2 from django.core.context_processors import csrf |
|
3 from django.core.urlresolvers import reverse |
3 from django.http import Http404 |
4 from django.http import Http404 |
4 from django.shortcuts import redirect |
5 from django.shortcuts import redirect |
5 from django.shortcuts import render_to_response |
6 from django.shortcuts import render_to_response |
6 |
7 |
7 from pytask.profile.forms import EditProfileForm |
8 from pytask.profile.forms import EditProfileForm |
39 if request.method == "POST": |
40 if request.method == "POST": |
40 form = EditProfileForm(request.POST, instance=profile) |
41 form = EditProfileForm(request.POST, instance=profile) |
41 |
42 |
42 if form.is_valid(): |
43 if form.is_valid(): |
43 form.save() |
44 form.save() |
44 return redirect("/profile/view") |
45 return redirect(reverse('view_profile')) |
45 else: |
46 else: |
46 context.update({"form":form}) |
47 context.update({"form":form}) |
47 return render_to_response("profile/edit.html", context) |
48 return render_to_response("profile/edit.html", context) |
48 else: |
49 else: |
49 form = EditProfileForm(instance=profile) |
50 form = EditProfileForm(instance=profile) |
55 """ get the list of notifications that are not deleted and display in |
56 """ get the list of notifications that are not deleted and display in |
56 datetime order.""" |
57 datetime order.""" |
57 |
58 |
58 user = request.user |
59 user = request.user |
59 |
60 |
60 active_notifications = user.notification_sent_to.filter(is_deleted=False).order_by('sent_date').reverse() |
61 active_notifications = user.notification_sent_to.filter( |
|
62 is_deleted=False).order_by('-sent_date') |
61 |
63 |
62 context = {'user':user, |
64 context = {'user':user, |
63 'notifications':active_notifications, |
65 'notifications':active_notifications, |
64 } |
66 } |
65 |
67 |
102 raise Http404 |
104 raise Http404 |
103 |
105 |
104 notification.is_deleted = True |
106 notification.is_deleted = True |
105 notification.save() |
107 notification.save() |
106 |
108 |
107 context = {'user':user, |
|
108 'notification':notification, |
|
109 'newest':newest, |
|
110 'newer':newer, |
|
111 'older':older, |
|
112 'oldest':oldest, |
|
113 } |
|
114 |
|
115 if older: |
109 if older: |
116 redirect_url = "/profile/notf/view/nid=%s"%older.uniq_key |
110 redirect_url = reverse('view_notification', |
|
111 kwargs={'notification_id': older.id}) |
117 else: |
112 else: |
118 redirect_url = "/profile/notf/browse" |
113 redirect_url = reverse('browse_notifications') |
119 |
114 |
120 return redirect(redirect_url) |
115 return redirect(redirect_url) |
121 |
116 |
122 @login_required |
117 @login_required |
123 def unread_notification(request, nid): |
118 def unread_notification(request, nid): |
132 raise Http404 |
127 raise Http404 |
133 |
128 |
134 notification.is_read = False |
129 notification.is_read = False |
135 notification.save() |
130 notification.save() |
136 |
131 |
137 context = {'user':user, |
|
138 'notification':notification, |
|
139 'newest':newest, |
|
140 'newer':newer, |
|
141 'older':older, |
|
142 'oldest':oldest, |
|
143 } |
|
144 |
|
145 if older: |
132 if older: |
146 redirect_url = "/profile/notf/view/nid=%s"%older.uniq_key |
133 redirect_url = reverse('view_notification', |
|
134 kwargs={'notification_id': older.id}) |
147 else: |
135 else: |
148 redirect_url = "/profile/notf/browse" |
136 redirect_url = reverse('browse_notifications') |
149 |
137 |
150 return redirect(redirect_url) |
138 return redirect(redirect_url) |
151 |
139 |
152 @login_required |
140 @login_required |
153 def view_user(request, uid): |
141 def view_user(request, uid): |