[FIX] website_sale: Discussion not working on product and gives '500: Internal Server Error' if public user try to comment on product (without login). Need to redirect to the login page (all user who want to write a comment have already buy the product and can use the portal login)
This commit is contained in:
parent
9a9bf02b1b
commit
6471fa6ddb
|
@ -346,7 +346,7 @@ class WebsiteForum(http.Controller):
|
||||||
body=kwargs.get('comment'),
|
body=kwargs.get('comment'),
|
||||||
type='comment',
|
type='comment',
|
||||||
subtype='mt_comment',
|
subtype='mt_comment',
|
||||||
context=dict(context, mail_create_nosubcribe=True))
|
context=dict(context, mail_create_nosubscribe=True))
|
||||||
return werkzeug.utils.redirect("/forum/%s/question/%s" % (slug(forum), slug(question)))
|
return werkzeug.utils.redirect("/forum/%s/question/%s" % (slug(forum), slug(question)))
|
||||||
|
|
||||||
@http.route('/forum/<model("forum.forum"):forum>/post/<model("forum.post"):post>/toggle_correct', type='json', auth="public", website=True)
|
@http.route('/forum/<model("forum.forum"):forum>/post/<model("forum.post"):post>/toggle_correct', type='json', auth="public", website=True)
|
||||||
|
|
|
@ -499,7 +499,7 @@ class Post(osv.Model):
|
||||||
}
|
}
|
||||||
message_id = self.pool['forum.post'].message_post(
|
message_id = self.pool['forum.post'].message_post(
|
||||||
cr, uid, question.id,
|
cr, uid, question.id,
|
||||||
context=dict(context, mail_create_nosubcribe=True),
|
context=dict(context, mail_create_nosubscribe=True),
|
||||||
**values)
|
**values)
|
||||||
|
|
||||||
# unlink the original answer, using SUPERUSER_ID to avoid karma issues
|
# unlink the original answer, using SUPERUSER_ID to avoid karma issues
|
||||||
|
|
|
@ -6,6 +6,7 @@ from openerp import http
|
||||||
from openerp.http import request
|
from openerp.http import request
|
||||||
from openerp.tools.translate import _
|
from openerp.tools.translate import _
|
||||||
from openerp.addons.website.models.website import slug
|
from openerp.addons.website.models.website import slug
|
||||||
|
from openerp.addons.web.controllers.main import login_redirect
|
||||||
|
|
||||||
PPG = 20 # Products Per Page
|
PPG = 20 # Products Per Page
|
||||||
PPR = 4 # Products Per Row
|
PPR = 4 # Products Per Row
|
||||||
|
@ -273,6 +274,8 @@ class website_sale(http.Controller):
|
||||||
|
|
||||||
@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", methods=['POST'], website=True)
|
||||||
def product_comment(self, product_template_id, **post):
|
def product_comment(self, product_template_id, **post):
|
||||||
|
if not request.session.uid:
|
||||||
|
return login_redirect()
|
||||||
cr, uid, context = request.cr, request.uid, request.context
|
cr, uid, context = request.cr, request.uid, request.context
|
||||||
if post.get('comment'):
|
if post.get('comment'):
|
||||||
request.registry['product.template'].message_post(
|
request.registry['product.template'].message_post(
|
||||||
|
@ -280,7 +283,7 @@ class website_sale(http.Controller):
|
||||||
body=post.get('comment'),
|
body=post.get('comment'),
|
||||||
type='comment',
|
type='comment',
|
||||||
subtype='mt_comment',
|
subtype='mt_comment',
|
||||||
context=dict(context, mail_create_nosubcribe=True))
|
context=dict(context, mail_create_nosubscribe=True))
|
||||||
return werkzeug.utils.redirect(request.httprequest.referrer + "#comments")
|
return werkzeug.utils.redirect(request.httprequest.referrer + "#comments")
|
||||||
|
|
||||||
@http.route(['/shop/pricelist'], type='http', auth="public", website=True)
|
@http.route(['/shop/pricelist'], type='http', auth="public", website=True)
|
||||||
|
|
Loading…
Reference in New Issue