Fixed #10585: comment redirects built from the `next` parameter now work correctly when `next` already contains a query string.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@10424 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
parent
eef2c5f6de
commit
6319470f88
|
@ -25,7 +25,8 @@ def next_redirect(data, default, default_view, **get_kwargs):
|
||||||
if next is None:
|
if next is None:
|
||||||
next = urlresolvers.reverse(default_view)
|
next = urlresolvers.reverse(default_view)
|
||||||
if get_kwargs:
|
if get_kwargs:
|
||||||
next += "?" + urllib.urlencode(get_kwargs)
|
joiner = ('?' in next) and '&' or '?'
|
||||||
|
next += joiner + urllib.urlencode(get_kwargs)
|
||||||
return HttpResponseRedirect(next)
|
return HttpResponseRedirect(next)
|
||||||
|
|
||||||
def confirmation_view(template, doc="Display a confirmation view."):
|
def confirmation_view(template, doc="Display a confirmation view."):
|
||||||
|
|
|
@ -207,3 +207,16 @@ class CommentViewTests(CommentTestCase):
|
||||||
self.assertTemplateUsed(response, "comments/posted.html")
|
self.assertTemplateUsed(response, "comments/posted.html")
|
||||||
self.assertEqual(response.context[0]["comment"], Comment.objects.get(pk=pk))
|
self.assertEqual(response.context[0]["comment"], Comment.objects.get(pk=pk))
|
||||||
|
|
||||||
|
def testCommentNextWithQueryString(self):
|
||||||
|
"""
|
||||||
|
The `next` key needs to handle already having a query string (#10585)
|
||||||
|
"""
|
||||||
|
a = Article.objects.get(pk=1)
|
||||||
|
data = self.getValidData(a)
|
||||||
|
data["next"] = "/somewhere/else/?foo=bar"
|
||||||
|
data["comment"] = "This is another comment"
|
||||||
|
response = self.client.post("/post/", data)
|
||||||
|
location = response["Location"]
|
||||||
|
match = re.search(r"^http://testserver/somewhere/else/\?foo=bar&c=\d+$", location)
|
||||||
|
self.failUnless(match != None, "Unexpected redirect location: %s" % location)
|
||||||
|
|
Loading…
Reference in New Issue