[FIX] : allow anonymus user to post inline comment
bzr revid: aja@tinyerp.com-20140224092255-t4zmt2lcnyetx81q
This commit is contained in:
@@ -239,7 +239,21 @@ class WebsiteBlog(http.Controller):
|
||||
response.set_cookie('visited_blogs', ','.join(map(str, visited_ids)))
|
||||
return response
|
||||
|
||||
def _blog_post_message(self, blog_post_id=0, **post):
|
||||
def _blog_post_message(self, user, blog_post_id=0, **post):
|
||||
cr, uid, context = request.cr, request.uid, request.context
|
||||
blog_post = request.registry['blog.post']
|
||||
message_id = blog_post.message_post(
|
||||
cr, SUPERUSER_ID, int(blog_post_id),
|
||||
body=post.get('comment'),
|
||||
type='comment',
|
||||
subtype='mt_comment',
|
||||
author_id= user.partner_id.id,
|
||||
discussion=post.get('discussion'),
|
||||
context=dict(context, mail_create_nosubcribe=True))
|
||||
return message_id
|
||||
|
||||
@http.route(['/blogpost/comment'], type='http', auth="public", methods=['POST'], website=True)
|
||||
def blog_post_comment(self, blog_post_id=0, **post):
|
||||
cr, uid, context = request.cr, request.uid, request.context
|
||||
if post.get('comment'):
|
||||
user = request.registry['res.users'].browse(cr, SUPERUSER_ID, uid, context=context)
|
||||
@@ -248,33 +262,24 @@ class WebsiteBlog(http.Controller):
|
||||
if group_id in [group.id for group in group_ids]:
|
||||
blog_post = request.registry['blog.post']
|
||||
blog_post.check_access_rights(cr, uid, 'read')
|
||||
message_id = blog_post.message_post(
|
||||
cr, SUPERUSER_ID, int(blog_post_id),
|
||||
body=post.get('comment'),
|
||||
type='comment',
|
||||
subtype='mt_comment',
|
||||
author_id=user.partner_id.id,
|
||||
discussion=post.get('discussion'),
|
||||
context=dict(context, mail_create_nosubcribe=True))
|
||||
return message_id
|
||||
|
||||
@http.route(['/blogpost/comment'], type='http', auth="public", methods=['POST'], website=True)
|
||||
def blog_post_comment(self, blog_post_id=0, **post):
|
||||
self._blog_post_message(blog_post_id, **post)
|
||||
self._blog_post_message(user, blog_post_id, **post)
|
||||
return werkzeug.utils.redirect(request.httprequest.referrer + "#comments")
|
||||
|
||||
@http.route(['/blogpost/post_discussion'], type='json', auth="public", website=True)
|
||||
def post_discussion(self, blog_post_id=0, **post):
|
||||
id = self._blog_post_message(blog_post_id, **post)
|
||||
mail_obj = request.registry.get('mail.message')
|
||||
cr, uid, context = request.cr, request.uid, request.context
|
||||
values = []
|
||||
post = mail_obj.browse(request.cr, SUPERUSER_ID, id)
|
||||
values = {
|
||||
"author_name": post.author_id.name,
|
||||
"date": post.date,
|
||||
"body": html2plaintext(post.body),
|
||||
"author_image": "data:image/png;base64,%s" % post.author_id.image,
|
||||
}
|
||||
if post.get('comment'):
|
||||
user = request.registry['res.users'].browse(cr, SUPERUSER_ID, uid, context=context)
|
||||
id = self._blog_post_message(user, blog_post_id, **post)
|
||||
mail_obj = request.registry.get('mail.message')
|
||||
post = mail_obj.browse(cr, SUPERUSER_ID, id)
|
||||
values = {
|
||||
"author_name": post.author_id.name,
|
||||
"date": post.date,
|
||||
"body": html2plaintext(post.body),
|
||||
"author_image": "data:image/png;base64,%s" % post.author_id.image,
|
||||
}
|
||||
return values
|
||||
|
||||
@http.route('/blogpost/new', type='http', auth="public", website=True, multilang=True)
|
||||
|
||||
@@ -14,7 +14,6 @@
|
||||
identifier: 'name',
|
||||
position: 'right',
|
||||
post_id: $('#blog_post_name').attr('data-oe-id'),
|
||||
document_user : false,
|
||||
content : false,
|
||||
};
|
||||
self.settings = $.extend({}, defaults, options);
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
$(document).ready(function() {
|
||||
var content = $("#blog_content p");
|
||||
if(content.length)
|
||||
new openerp.website.blog_discussion({'document_user': $('#is_document_user').length, 'content' : content});
|
||||
new openerp.website.blog_discussion({'content' : content});
|
||||
$('.cover_footer').on('click',page_transist);
|
||||
$('a[href^="#blog_content"]').on('click', animate);
|
||||
$("p").share();
|
||||
@@ -37,7 +37,7 @@ $(document).ready(function() {
|
||||
$(document).find('a[href^="#blog_content"]').on('click', animate);
|
||||
var content = $(document).find("#blog_content p");
|
||||
if (content)
|
||||
new openerp.website.blog_discussion({'document_user': $('#is_document_user').length, 'content' : content});
|
||||
new openerp.website.blog_discussion({'content' : content});
|
||||
$("p").share();
|
||||
});
|
||||
if (newLocation != window.location) {
|
||||
|
||||
@@ -20,10 +20,9 @@
|
||||
<div class="mycontent hidden">
|
||||
<input name="discussion" t-att-value="identifier" type="hidden"/>
|
||||
<input name="blog_post_id" t-att-value="options.post_id" type="hidden"/>
|
||||
<textarea t-att-class="options.document_user ? 'mb8 form-control' : 'mb8 form-control hidden'" rows="2" id="comment" placeholder="Write a comment..."/>
|
||||
<button id='comment_post' t-att-class="options.document_user ? 'btn btn-primary btn-xs mb8 mt4' : 'btn btn-primary btn-xs mb8 mt4 hidden'">Post</button>
|
||||
<textarea class="mb8 form-control" rows="2" id="comment" placeholder="Write a comment..."/>
|
||||
<button id='comment_post' class="btn btn-primary btn-xs mb8 mt4">Post</button>
|
||||
<div class="discussion_history"/>
|
||||
<a t-att-class="options.document_user ? 'btn btn-block btn-success hidden' : 'btn btn-block btn-success'" href="/web/login">Sign In</a>
|
||||
</div>
|
||||
</t>
|
||||
</templates>
|
||||
|
||||
Reference in New Issue
Block a user