summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicolas Lempereur <nle@odoo.com>2015-06-16 19:45:43 +0200
committerNicolas Lempereur <nle@odoo.com>2015-06-17 11:33:20 +0200
commit3f1e99c4b95d824b044297b47b69fe4ed4eae28c (patch)
treee38515e6bfdfa9b0f346c6e0195a09273d9a13f1
parentdca1894b5d3567cb1ed209ce1069dc365489d0e6 (diff)
[FIX] web, website_form_website_sale: form and login
Partial backport of commit 093e39bd. When a flow is stopped by a login redirection, some data (e.g: a product comment being posted) could be lost. This commit in this case convert POST request data to GET data (so it is possible to add a GET controller which after login will terminate the action). closes #7100 opw-642350
-rw-r--r--addons/web/controllers/main.py8
-rw-r--r--addons/website_forum/controllers/main.py4
-rw-r--r--addons/website_sale/controllers/main.py4
3 files changed, 8 insertions, 8 deletions
diff --git a/addons/web/controllers/main.py b/addons/web/controllers/main.py
index 340b57da5f1..7452f5644fc 100644
--- a/addons/web/controllers/main.py
+++ b/addons/web/controllers/main.py
@@ -311,12 +311,12 @@ def set_cookie_and_redirect(redirect_url):
def login_redirect():
url = '/web/login?'
- if request.debug:
- url += 'debug&'
+ # built the redirect url, keeping all the query parameters of the url
+ redirect_url = '%s?%s' % (request.httprequest.base_url, werkzeug.urls.url_encode(request.params))
return """<html><head><script>
- window.location = '%sredirect=' + encodeURIComponent(window.location);
+ window.location = '%sredirect=' + encodeURIComponent("%s");
</script></head></html>
- """ % (url,)
+ """ % (url, redirect_url)
def load_actions_from_ir_values(key, key2, models, meta):
Values = request.session.model('ir.values')
diff --git a/addons/website_forum/controllers/main.py b/addons/website_forum/controllers/main.py
index 7a8c9fc27cd..4323e03720f 100644
--- a/addons/website_forum/controllers/main.py
+++ b/addons/website_forum/controllers/main.py
@@ -323,7 +323,7 @@ class WebsiteForum(http.Controller):
# Post
# --------------------------------------------------
- @http.route('/forum/<model("forum.forum"):forum>/post/<model("forum.post"):post>/new', type='http', auth="public", methods=['POST'], website=True)
+ @http.route('/forum/<model("forum.forum"):forum>/post/<model("forum.post"):post>/new', type='http', auth="public", website=True)
def post_new(self, forum, post, **kwargs):
if not request.session.uid:
return login_redirect()
@@ -339,7 +339,7 @@ class WebsiteForum(http.Controller):
}, context=request.context)
return werkzeug.utils.redirect("/forum/%s/question/%s" % (slug(forum), slug(post)))
- @http.route('/forum/<model("forum.forum"):forum>/post/<model("forum.post"):post>/comment', type='http', auth="public", methods=['POST'], website=True)
+ @http.route('/forum/<model("forum.forum"):forum>/post/<model("forum.post"):post>/comment', type='http', auth="public", website=True)
def post_comment(self, forum, post, **kwargs):
if not request.session.uid:
return login_redirect()
diff --git a/addons/website_sale/controllers/main.py b/addons/website_sale/controllers/main.py
index b4a93597630..2d9a3926270 100644
--- a/addons/website_sale/controllers/main.py
+++ b/addons/website_sale/controllers/main.py
@@ -277,7 +277,7 @@ class website_sale(http.Controller):
}
return request.website.render("website_sale.product", values)
- @http.route(['/shop/product/comment/<int:product_template_id>'], type='http', auth="public", methods=['POST'], website=True)
+ @http.route(['/shop/product/comment/<int:product_template_id>'], type='http', auth="public", website=True)
def product_comment(self, product_template_id, **post):
if not request.session.uid:
return login_redirect()
@@ -289,7 +289,7 @@ class website_sale(http.Controller):
type='comment',
subtype='mt_comment',
context=dict(context, mail_create_nosubscribe=True))
- return werkzeug.utils.redirect(request.httprequest.referrer + "#comments")
+ return werkzeug.utils.redirect('/shop/product/%s#comments' % product_template_id)
@http.route(['/shop/pricelist'], type='http', auth="public", website=True)
def pricelist(self, promo, **post):