Ticket #8968: fix-next-redirect.diff

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

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

  • django/contrib/comments/views/moderation.

    old new  
    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
     
    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)
     
    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.
     
    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(), 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)
     
    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.
     
    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)
Back to Top