diff --git a/addons/website_blog/controllers/main.py b/addons/website_blog/controllers/main.py index cb655585d04..ca56ac50354 100644 --- a/addons/website_blog/controllers/main.py +++ b/addons/website_blog/controllers/main.py @@ -181,24 +181,25 @@ class WebsiteBlog(http.Controller): ] return simplejson.dumps(blog_post_data) - @website.route(['/blog//post'], type='http', auth="public") + @website.route(['/blog//comment'], type='http', auth="public") def blog_post_comment(self, blog_post_id=None, **post): cr, uid, context = request.cr, request.uid, request.context - url = request.httprequest.host_url - request.session.body = post.get('body') - if request.context['is_public_user']: # purpose of this ? + + # This should only happen if the user has logged off in one tab + # but posts a comment from another tab (kept open) + # Normally, the comment form is hidden (in the template) in public mode + if request.context['is_public_user']: + url = request.httprequest.host_url return '%s/web#action=redirect&url=%s/blog/%s/post' % (url, url, blog_post_id) - if request.session.get('body') and blog_post_id: - request.registry['blog.post'].message_post( - cr, uid, blog_post_id, - body=request.session.body, - type='comment', - subtype='mt_comment', - context=dict(context, mail_create_nosubcribe=True)) - request.session.body = False + request.registry['blog.post'].message_post( + cr, uid, blog_post_id, + body=post.get('comment'), + type='comment', + subtype='mt_comment', + context=dict(context, mail_create_nosubcribe=True)) - return werkzeug.utils.redirect("/blog/%s/?enable_editor=1" % (blog_post_id)) + return werkzeug.utils.redirect("/blog/%s/" % (blog_post_id)) @website.route(['/blog//new'], type='http', auth="public") def blog_post_create(self, category_id=None, **post): diff --git a/addons/website_blog/static/src/js/website_blog.js b/addons/website_blog/static/src/js/website_blog.js index 84e40ec3f12..5d9a83162dd 100644 --- a/addons/website_blog/static/src/js/website_blog.js +++ b/addons/website_blog/static/src/js/website_blog.js @@ -25,16 +25,4 @@ $(document).ready(function () { } }); - var $form = $('.js_website_blog form#comment'); - $form.submit(function (e) { - e.preventDefault(); - var error = $form.find("textarea").val().length < 3; - $form.find("textarea").toggleClass("has-error", error); - if (!error) { - $form.css("visibility", "hidden"); - $.post(window.location.pathname + '/post', {'body': $form.find("textarea").val()}, function (url) { - window.location.href = url - }); - } - }); }); \ No newline at end of file diff --git a/addons/website_blog/views/website_blog_templates.xml b/addons/website_blog/views/website_blog_templates.xml index 4e52e8bdec3..65b04aea9f5 100644 --- a/addons/website_blog/views/website_blog_templates.xml +++ b/addons/website_blog/views/website_blog_templates.xml @@ -132,11 +132,11 @@

Leave a Comment

-
- +