From 3f1e99c4b95d824b044297b47b69fe4ed4eae28c Mon Sep 17 00:00:00 2001 From: Nicolas Lempereur Date: Tue, 16 Jun 2015 19:45:43 +0200 Subject: [PATCH] [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 --- addons/web/controllers/main.py | 8 ++++---- addons/website_forum/controllers/main.py | 4 ++-- addons/website_sale/controllers/main.py | 4 ++-- 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 """ - """ % (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//post//new', type='http', auth="public", methods=['POST'], website=True) + @http.route('/forum//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//post//comment', type='http', auth="public", methods=['POST'], website=True) + @http.route('/forum//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/'], type='http', auth="public", methods=['POST'], website=True) + @http.route(['/shop/product/comment/'], 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):