[IMP] anonymous for website_blog
bzr revid: fp@tinyerp.com-20140323195531-84hnzo5f950r4eg7
This commit is contained in:
parent
eeca54b04c
commit
f51a366ea7
|
@ -205,7 +205,7 @@ class mail_message(osv.Model):
|
|||
return '%s <%s@%s>' % (this.name, this.alias_name, this.alias_domain)
|
||||
elif this.email:
|
||||
return '%s <%s>' % (this.name, this.email)
|
||||
raise osv.except_osv(_('Invalid Action!'), _("Unable to send email, please configure the sender's email address or alias."))
|
||||
return False
|
||||
|
||||
def _get_default_author(self, cr, uid, context=None):
|
||||
return self.pool.get('res.users').browse(cr, SUPERUSER_ID, uid, context=context).partner_id.id
|
||||
|
@ -843,7 +843,8 @@ class mail_message(osv.Model):
|
|||
values['reply_to'] = self._get_reply_to(cr, uid, values, context=context)
|
||||
|
||||
newid = super(mail_message, self).create(cr, uid, values, context)
|
||||
self._notify(cr, uid, newid, context=context,
|
||||
if values['email_from']:
|
||||
self._notify(cr, uid, newid, context=context,
|
||||
force_send=context.get('mail_notify_force_send', True),
|
||||
user_signature=context.get('mail_notify_user_signature', True))
|
||||
# TDE FIXME: handle default_starred. Why not setting an inv on starred ?
|
||||
|
|
|
@ -210,11 +210,11 @@ class WebsiteBlog(http.Controller):
|
|||
cr, uid, context = request.cr, request.uid, request.context
|
||||
blog_post = request.registry['blog.post']
|
||||
message_id = blog_post.message_post(
|
||||
cr, uid, int(blog_post_id),
|
||||
cr, SUPERUSER_ID, int(blog_post_id),
|
||||
body=post.get('comment'),
|
||||
type='comment',
|
||||
subtype='mt_comment',
|
||||
author_id= user.partner_id.id,
|
||||
author_id=False,
|
||||
discussion=post.get('discussion'),
|
||||
context=dict(context, mail_create_nosubcribe=True))
|
||||
return message_id
|
||||
|
@ -237,12 +237,14 @@ class WebsiteBlog(http.Controller):
|
|||
user = request.registry['res.users'].browse(cr, uid, 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, uid, id)
|
||||
post = mail_obj.browse(cr, SUPERUSER_ID, id)
|
||||
values = {
|
||||
"author_name": post.author_id.name,
|
||||
"author_name": post.author_id and post.author_id.name or _('Anonymous'),
|
||||
"date": post.date,
|
||||
"body": html2plaintext(post.body),
|
||||
"author_image": "data:image/png;base64,%s" % post.author_id.image,
|
||||
"author_image": post.author_id and \
|
||||
("data:image/png;base64,%s" % post.author_id.image) or \
|
||||
'/website_blog/static/src/img/anonymous.png',
|
||||
}
|
||||
return values
|
||||
|
||||
|
@ -278,14 +280,16 @@ class WebsiteBlog(http.Controller):
|
|||
cr, uid, context = request.cr, request.uid, request.context
|
||||
mail_obj = request.registry.get('mail.message')
|
||||
values = []
|
||||
ids = mail_obj.search(cr, uid, [('res_id', '=', int(post_id)) ,('model','=','blog.post'), ('discussion', '=', discussion)])
|
||||
ids = mail_obj.search(cr, SUPERUSER_ID, [('res_id', '=', int(post_id)) ,('model','=','blog.post'), ('discussion', '=', discussion)])
|
||||
if ids:
|
||||
for post in mail_obj.browse(cr, uid, ids, context=context):
|
||||
for post in mail_obj.browse(cr, SUPERUSER_ID, ids, context=context):
|
||||
values.append({
|
||||
"author_name": post.author_id.name,
|
||||
"author_name": post.author_id and post.author_id.name or _('Anonymous'),
|
||||
"author_image": post.author_id and \
|
||||
("data:image/png;base64,%s" % post.author_id.image) or \
|
||||
'/website_blog/static/src/img/anonymous.png',
|
||||
"date": post.date,
|
||||
'body': html2plaintext(post.body),
|
||||
'author_image': "data:image/png;base64,%s" % post.author_id.image,
|
||||
})
|
||||
return values
|
||||
|
||||
|
|
Binary file not shown.
After Width: | Height: | Size: 1.5 KiB |
|
@ -13,7 +13,7 @@
|
|||
var defaults = {
|
||||
identifier: 'name',
|
||||
position: 'right',
|
||||
post_id: $('#blog_post_name').attr('data-oe-id'),
|
||||
post_id: $('#blog_post_name').attr('data-blog-id'),
|
||||
content : false,
|
||||
};
|
||||
self.settings = $.extend({}, defaults, options);
|
||||
|
|
|
@ -6,8 +6,11 @@
|
|||
<img class="media-object img-circle" t-att-src="res.author_image" style="width: 30px;"/>
|
||||
</div>
|
||||
<div class="media-body">
|
||||
<small t-esc='res.author_name'/>
|
||||
<div t-esc='res.body'/>
|
||||
<small class="text-muted">
|
||||
by
|
||||
<span t-esc='res.author_name'/>
|
||||
</small>
|
||||
</div>
|
||||
</li>
|
||||
</t>
|
||||
|
@ -16,7 +19,7 @@
|
|||
<input name="discussion" t-att-value="identifier" type="hidden"/>
|
||||
<input name="blog_post_id" t-att-value="options.post_id" type="hidden"/>
|
||||
<textarea class="mb8 form-control" rows="2" id="comment" placeholder="Write a comment..."/>
|
||||
<button id='comment_post' class="btn btn-primary btn-xs mb4">Post</button>
|
||||
<button id='comment_post' class="btn btn-primary btn-xs mb8">Post</button>
|
||||
<div class="discussion_history"/>
|
||||
</div>
|
||||
</t>
|
||||
|
|
|
@ -179,7 +179,7 @@
|
|||
</div>
|
||||
</div>
|
||||
<div class="blog_title">
|
||||
<h1 t-field="blog_post.name" id="blog_post_name"/>
|
||||
<h1 t-field="blog_post.name" id="blog_post_name" t-att-data-blog-id="blog_post.id"/>
|
||||
<h2 t-field="blog_post.sub_title"/>
|
||||
<div>
|
||||
<img class="img-circle" t-att-src="'/website/image?model=blog.post&field=author_image&id='+str(blog_post.id)" style="width: 30px; margin-right: 10px;"/>
|
||||
|
@ -195,11 +195,12 @@
|
|||
<div id="blog_content" t-field="blog_post.content"/>
|
||||
</div>
|
||||
|
||||
<section id="comments" class="container">
|
||||
<ul class="media-list read_width" id="comments-list">
|
||||
<section id="comments" class="read_width" t-if="blog_post.website_message_ids">
|
||||
<hr/>
|
||||
<ul class="media-list" id="comments-list">
|
||||
<li t-foreach="blog_post.website_message_ids" t-as="message" class="media">
|
||||
<span class="pull-left">
|
||||
<img class="media-object img img-circle" t-att-src="'/website/image?model=res.partner&field=image_small&id='+str(message.author_id.id)"/>
|
||||
<img class="media-object img img-circle" t-att-src="'/website/image?model=mail.message&field=author_avatar&id='+str(message.id)" style="width: 30px"/>
|
||||
</span>
|
||||
<div class="media-body">
|
||||
<t t-call="website.publish_short">
|
||||
|
@ -256,11 +257,10 @@
|
|||
groups="website_mail.group_comment">
|
||||
<xpath expr="//ul[@id='comments-list']" position="before">
|
||||
<section class="mb32 read_width css_editable_mode_hidden">
|
||||
<hr/>
|
||||
<form id="comment" t-attf-action="/blogpost/comment" method="POST">
|
||||
<div class="media">
|
||||
<span class="pull-left">
|
||||
<img class="img img-circle media-object" t-att-src="'/website/image?model=res.partner&field=image_small&id='+str(user_id.partner_id.id)"/>
|
||||
<img class="img img-circle media-object" t-att-src="'/website/image?model=res.partner&field=image_small&id='+str(user_id.partner_id.id)" style="width: 30px"/>
|
||||
</span>
|
||||
<div class="media-body">
|
||||
<input name="blog_post_id" t-att-value="blog_post.id" type="hidden"/>
|
||||
|
|
Loading…
Reference in New Issue