Code

Ticket #8968: fix-next-redirect.diff

File fix-next-redirect.diff, 2.5 KB (added by neithere, 6 years ago)

This patch enables correct redirecting from moderation views by passing a next parameter via GET

Line 
1--- django/contrib/comments/views/moderation.orig.py    2008-10-13 18:03:18.000000000 +0600
2+++ django/contrib/comments/views/moderation.py 2008-10-25 01:56:53.000000000 +0600
3@@ -9,7 +9,7 @@
4 from django.contrib.comments import signals
5 
6 #@login_required
7-def flag(request, comment_id, next=None):
8+def flag(request, comment_id):
9     """
10     Flags a comment. Confirmation on GET, action on POST.
11 
12@@ -34,10 +34,11 @@
13             created = created,
14             request = request,
15         )
16-        return next_redirect(request.POST.copy(), next, flag_done, c=comment.pk)
17+        return next_redirect(request.POST.copy(), None, flag_done, c=comment.pk)
18 
19     # Render a form on GET
20     else:
21+        next = request.GET.get('next')
22         return render_to_response('comments/flag.html',
23             {'comment': comment, "next": next},
24             template.RequestContext(request)
25@@ -45,7 +46,7 @@
26 flag = login_required(flag)
27 
28 #@permission_required("comments.delete_comment")
29-def delete(request, comment_id, next=None):
30+def delete(request, comment_id):
31     """
32     Deletes a comment. Confirmation on GET, action on POST. Requires the "can
33     moderate comments" permission.
34@@ -74,10 +75,11 @@
35             created = created,
36             request = request,
37         )
38-        return next_redirect(request.POST.copy(), next, delete_done, c=comment.pk)
39+        return next_redirect(request.POST.copy(), None, delete_done, c=comment.pk)
40 
41     # Render a form on GET
42     else:
43+        next = request.GET.get('next')
44         return render_to_response('comments/delete.html',
45             {'comment': comment, "next": next},
46             template.RequestContext(request)
47@@ -85,7 +87,7 @@
48 delete = permission_required("comments.can_moderate")(delete)
49 
50 #@permission_required("comments.can_moderate")
51-def approve(request, comment_id, next=None):
52+def approve(request, comment_id):
53     """
54     Approve a comment (that is, mark it as public and non-removed). Confirmation
55     on GET, action on POST. Requires the "can moderate comments" permission.
56@@ -117,10 +119,11 @@
57             created = created,
58             request = request,
59         )
60-        return next_redirect(request.POST.copy(), next, approve_done, c=comment.pk)
61+        return next_redirect(request.POST.copy(), None, approve_done, c=comment.pk)
62 
63     # Render a form on GET
64     else:
65+        next = request.GET.get('next')
66         return render_to_response('comments/approve.html',
67             {'comment': comment, "next": next},
68             template.RequestContext(request)