Ticket #11110: next_redirect_via_comment_preview.diff

File next_redirect_via_comment_preview.diff, 1.7 KB (added by Kevin Fullerton, 15 years ago)
  • django/contrib/comments/views/comments.py

     
    8080            template_list, {
    8181                "comment" : form.data.get("comment", ""),
    8282                "form" : form,
    83                 "next": next,
     83                "next": next or data.get("next", None),
    8484            },
    8585            RequestContext(request, {})
    8686        )
  • tests/regressiontests/comment_tests/tests/comment_view_tests.py

     
    219219        location = response["Location"]       
    220220        match = re.search(r"^http://testserver/somewhere/else/\?foo=bar&c=\d+$", location)
    221221        self.failUnless(match != None, "Unexpected redirect location: %s" % location)
    222        
    223  No newline at end of file
     222       
     223    def testCommentPreviewWithNext(self):
     224        """
     225        The preview view needs to handle the `next` key being passed in (#11110)
     226        """
     227        a = Article.objects.get(pk=1)
     228        data = self.getValidData(a)
     229        data["preview"] = "Preview"
     230        data["next"] = "/somewhere/else/"
     231        response = self.client.post("/post/", data)
     232        self.assertTemplateUsed(response, "comments/preview.html")
     233        self.assertEqual(response.status_code, 200)
     234        self.assertEqual(response.context[0]["next"], data["next"])
Back to Top