[FIX] CMS: comments should work in website_blog
bzr revid: ddm@openerp.com-20131104172356-55n900jnzwjdi41b
This commit is contained in:
@@ -181,24 +181,25 @@ class WebsiteBlog(http.Controller):
|
||||
]
|
||||
return simplejson.dumps(blog_post_data)
|
||||
|
||||
@website.route(['/blog/<int:blog_post_id>/post'], type='http', auth="public")
|
||||
@website.route(['/blog/<int:blog_post_id>/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/<int:category_id>/new'], type='http', auth="public")
|
||||
def blog_post_create(self, category_id=None, **post):
|
||||
|
||||
@@ -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
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
@@ -132,11 +132,11 @@
|
||||
<t t-if="not is_public_user">
|
||||
<section groups="group_website_blog_reply" class="mb32">
|
||||
<h4>Leave a Comment</h4>
|
||||
<form id="comment" t-attf-action="/blog/#{blog_post.id}/post#post"
|
||||
<form id="comment" t-attf-action="/blog/#{blog_post.id}/comment"
|
||||
method="POST">
|
||||
<img class="img pull-left img-rounded" t-att-src="'/website/image?model=res.partner&field=image_small&id='+str(user_id.partner_id.id)" style="width: 50px; margin-right: 10px;"/>
|
||||
<div class="pull-left mb32" style="width: 75%%">
|
||||
<textarea rows="3" class="form-control" placeholder="Write a comment..."></textarea>
|
||||
<textarea rows="3" name="comment" class="form-control" placeholder="Write a comment..."></textarea>
|
||||
<button type="submit" class="btn btn-danger mt8">Post</button>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
Reference in New Issue
Block a user