[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
This commit is contained in:
parent
dca1894b5d
commit
3f1e99c4b9
|
@ -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')
|
||||
|
|
|
@ -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()
|
||||
|
|
|
@ -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):
|
||||
|
|
Loading…
Reference in New Issue