diff --git a/django/contrib/comments/views/moderation.py b/django/contrib/comments/views/moderation.py
index 3334b09..9389580 100644
a
|
b
|
from django.contrib import comments
|
9 | 9 | from django.contrib.comments import signals |
10 | 10 | |
11 | 11 | #@login_required |
12 | | def flag(request, comment_id, next=None): |
| 12 | def flag(request, comment_id): |
13 | 13 | """ |
14 | 14 | Flags a comment. Confirmation on GET, action on POST. |
15 | 15 | |
… |
… |
def flag(request, comment_id, next=None):
|
34 | 34 | created = created, |
35 | 35 | request = request, |
36 | 36 | ) |
37 | | return next_redirect(request.POST.copy(), next, flag_done, c=comment.pk) |
| 37 | return next_redirect(request.POST.copy(), None, flag_done, c=comment.pk) |
38 | 38 | |
39 | 39 | # Render a form on GET |
40 | 40 | else: |
| 41 | next = request.GET.get('next') |
41 | 42 | return render_to_response('comments/flag.html', |
42 | 43 | {'comment': comment, "next": next}, |
43 | 44 | template.RequestContext(request) |
… |
… |
def flag(request, comment_id, next=None):
|
45 | 46 | flag = login_required(flag) |
46 | 47 | |
47 | 48 | #@permission_required("comments.delete_comment") |
48 | | def delete(request, comment_id, next=None): |
| 49 | def delete(request, comment_id): |
49 | 50 | """ |
50 | 51 | Deletes a comment. Confirmation on GET, action on POST. Requires the "can |
51 | 52 | moderate comments" permission. |
… |
… |
def delete(request, comment_id, next=None):
|
74 | 75 | created = created, |
75 | 76 | request = request, |
76 | 77 | ) |
77 | | return next_redirect(request.POST.copy(), next, delete_done, c=comment.pk) |
| 78 | return next_redirect(request.POST.copy(), request.GET.get('next',None), delete_done, c=comment.pk) |
78 | 79 | |
79 | 80 | # Render a form on GET |
80 | 81 | else: |
| 82 | next = request.GET.get('next') |
81 | 83 | return render_to_response('comments/delete.html', |
82 | 84 | {'comment': comment, "next": next}, |
83 | 85 | template.RequestContext(request) |
… |
… |
def delete(request, comment_id, next=None):
|
85 | 87 | delete = permission_required("comments.can_moderate")(delete) |
86 | 88 | |
87 | 89 | #@permission_required("comments.can_moderate") |
88 | | def approve(request, comment_id, next=None): |
| 90 | def approve(request, comment_id): |
89 | 91 | """ |
90 | 92 | Approve a comment (that is, mark it as public and non-removed). Confirmation |
91 | 93 | on GET, action on POST. Requires the "can moderate comments" permission. |
… |
… |
def approve(request, comment_id, next=None):
|
117 | 119 | created = created, |
118 | 120 | request = request, |
119 | 121 | ) |
120 | | return next_redirect(request.POST.copy(), next, approve_done, c=comment.pk) |
| 122 | return next_redirect(request.POST.copy(), None, approve_done, c=comment.pk) |
121 | 123 | |
122 | 124 | # Render a form on GET |
123 | 125 | else: |
| 126 | next = request.GET.get('next') |
124 | 127 | return render_to_response('comments/approve.html', |
125 | 128 | {'comment': comment, "next": next}, |
126 | 129 | template.RequestContext(request) |
diff --git a/tests/regressiontests/comment_tests/tests/moderation_view_tests.py b/tests/regressiontests/comment_tests/tests/moderation_view_tests.py
index b9eadd7..f0d8cbd 100644
a
|
b
|
from django.contrib.auth.models import User, Permission
|
3 | 3 | from django.contrib.contenttypes.models import ContentType |
4 | 4 | from regressiontests.comment_tests.tests import CommentTestCase |
5 | 5 | from django.contrib.comments import signals |
6 | | |
| 6 | import re |
7 | 7 | class FlagViewTests(CommentTestCase): |
8 | 8 | |
9 | 9 | def testFlagGet(self): |
… |
… |
class DeleteViewTests(CommentTestCase):
|
92 | 92 | self.client.login(username="normaluser", password="normaluser") |
93 | 93 | response = self.client.post("/delete/%d/" % pk) |
94 | 94 | self.assertEqual(response["Location"], "http://testserver/deleted/?c=%d" % pk) |
| 95 | |
| 96 | response = self.client.post("/delete/%d/" % pk,{"next":"/somewhere/else/"}) |
| 97 | location = response["Location"] |
| 98 | match = re.search(r"^http://testserver/somewhere/else/\?c=\d+$", location) |
| 99 | self.failUnless(match != None, "Unexpected redirect location: %s" % location) |
95 | 100 | c = Comment.objects.get(pk=pk) |
96 | 101 | self.failUnless(c.is_removed) |
97 | 102 | self.assertEqual(c.flags.filter(flag=CommentFlag.MODERATOR_DELETION, user__username="normaluser").count(), 1) |
… |
… |
class DeleteViewTests(CommentTestCase):
|
106 | 111 | |
107 | 112 | # Post a comment and check the signals |
108 | 113 | self.testDeletePost() |
109 | | self.assertEqual(received_signals, [signals.comment_was_flagged]) |
| 114 | self.assertEqual(received_signals, [signals.comment_was_flagged,signals.comment_was_flagged]) |
110 | 115 | |
111 | 116 | def testDeletedView(self): |
112 | 117 | comments = self.createSomeComments() |
113 | 118 | pk = comments[0].pk |
114 | 119 | response = self.client.get("/deleted/", data={"c":pk}) |
115 | 120 | self.assertTemplateUsed(response, "comments/deleted.html") |
| 121 | |
116 | 122 | |
117 | 123 | class ApproveViewTests(CommentTestCase): |
118 | 124 | |