[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:
Christophe Matthieu 2015-01-05 12:25:00 +01:00
parent 9a9bf02b1b
commit 6471fa6ddb
3 changed files with 6 additions and 3 deletions

View File

@ -346,7 +346,7 @@ class WebsiteForum(http.Controller):
body=kwargs.get('comment'),
type='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)))
@http.route('/forum/<model("forum.forum"):forum>/post/<model("forum.post"):post>/toggle_correct', type='json', auth="public", website=True)

View File

@ -499,7 +499,7 @@ class Post(osv.Model):
}
message_id = self.pool['forum.post'].message_post(
cr, uid, question.id,
context=dict(context, mail_create_nosubcribe=True),
context=dict(context, mail_create_nosubscribe=True),
**values)
# unlink the original answer, using SUPERUSER_ID to avoid karma issues

View File

@ -6,6 +6,7 @@ from openerp import http
from openerp.http import request
from openerp.tools.translate import _
from openerp.addons.website.models.website import slug
from openerp.addons.web.controllers.main import login_redirect
PPG = 20 # Products Per Page
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)
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
if post.get('comment'):
request.registry['product.template'].message_post(
@ -280,7 +283,7 @@ class website_sale(http.Controller):
body=post.get('comment'),
type='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")
@http.route(['/shop/pricelist'], type='http', auth="public", website=True)