Ticket #8968: fix_8968.patch

File fix_8968.patch, 4.8 KB (added by Kevin Kubasik, 16 years ago)
  • django/contrib/comments/views/moderation.py

    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  
    99from django.contrib.comments import signals
    1010
    1111#@login_required
    12 def flag(request, comment_id, next=None):
     12def flag(request, comment_id):
    1313    """
    1414    Flags a comment. Confirmation on GET, action on POST.
    1515
    def flag(request, comment_id, next=None):  
    3434            created = created,
    3535            request = request,
    3636        )
    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)
    3838
    3939    # Render a form on GET
    4040    else:
     41        next = request.GET.get('next')
    4142        return render_to_response('comments/flag.html',
    4243            {'comment': comment, "next": next},
    4344            template.RequestContext(request)
    def flag(request, comment_id, next=None):  
    4546flag = login_required(flag)
    4647
    4748#@permission_required("comments.delete_comment")
    48 def delete(request, comment_id, next=None):
     49def delete(request, comment_id):
    4950    """
    5051    Deletes a comment. Confirmation on GET, action on POST. Requires the "can
    5152    moderate comments" permission.
    def delete(request, comment_id, next=None):  
    7475            created = created,
    7576            request = request,
    7677        )
    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)
    7879
    7980    # Render a form on GET
    8081    else:
     82        next = request.GET.get('next')
    8183        return render_to_response('comments/delete.html',
    8284            {'comment': comment, "next": next},
    8385            template.RequestContext(request)
    def delete(request, comment_id, next=None):  
    8587delete = permission_required("comments.can_moderate")(delete)
    8688
    8789#@permission_required("comments.can_moderate")
    88 def approve(request, comment_id, next=None):
     90def approve(request, comment_id):
    8991    """
    9092    Approve a comment (that is, mark it as public and non-removed). Confirmation
    9193    on GET, action on POST. Requires the "can moderate comments" permission.
    def approve(request, comment_id, next=None):  
    117119            created = created,
    118120            request = request,
    119121        )
    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)
    121123
    122124    # Render a form on GET
    123125    else:
     126        next = request.GET.get('next')
    124127        return render_to_response('comments/approve.html',
    125128            {'comment': comment, "next": next},
    126129            template.RequestContext(request)
  • tests/regressiontests/comment_tests/tests/moderation_view_tests.py

    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  
    33from django.contrib.contenttypes.models import ContentType
    44from regressiontests.comment_tests.tests import CommentTestCase
    55from django.contrib.comments import signals
    6 
     6import re
    77class FlagViewTests(CommentTestCase):
    88
    99    def testFlagGet(self):
    class DeleteViewTests(CommentTestCase):  
    9292        self.client.login(username="normaluser", password="normaluser")
    9393        response = self.client.post("/delete/%d/" % pk)
    9494        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)
    95100        c = Comment.objects.get(pk=pk)
    96101        self.failUnless(c.is_removed)
    97102        self.assertEqual(c.flags.filter(flag=CommentFlag.MODERATOR_DELETION, user__username="normaluser").count(), 1)
    class DeleteViewTests(CommentTestCase):  
    106111
    107112        # Post a comment and check the signals
    108113        self.testDeletePost()
    109         self.assertEqual(received_signals, [signals.comment_was_flagged])
     114        self.assertEqual(received_signals, [signals.comment_was_flagged,signals.comment_was_flagged])
    110115
    111116    def testDeletedView(self):
    112117        comments = self.createSomeComments()
    113118        pk = comments[0].pk
    114119        response = self.client.get("/deleted/", data={"c":pk})
    115120        self.assertTemplateUsed(response, "comments/deleted.html")
     121
    116122
    117123class ApproveViewTests(CommentTestCase):
    118124
Back to Top