[FIX] website: correct redirect with correct lang

When forcing another language that the current one (the cookie one) in an
url, the requested lang wasn't set correctly in redirect url, but the
cookie was, resulting in multiple redirect which ends with initial lang.

A side effect of this error was the inability to edit website page when
default lang is not en_US and user not in default lang.

The request context must be reset before being used by
`request.redirect` (in `url_for` method).
This commit is contained in:
Christophe Simonis
2017-03-10 18:31:21 +01:00
parent beaea311e6
commit c9e3d93ad0
+1 -1
View File
@@ -196,9 +196,9 @@ class Http(models.AbstractModel):
if request.lang != request.website.default_lang_code:
path.insert(1, request.lang)
path = '/'.join(path) or '/'
request.context = context
redirect = request.redirect(path + '?' + request.httprequest.query_string)
redirect.set_cookie('website_lang', request.lang)
request.context = context
return redirect
elif url_lang:
request.uid = None