[REM] : unsed import
-> author_iamge field [IMP] : odrder of imports -> mechanism to post for anonymus user bzr revid: aja@tinyerp.com-20140327072334-4wwt7ady4vmam91e
This commit is contained in:
parent
588c44a6c4
commit
e5f0562265
|
@ -19,19 +19,15 @@
|
|||
#
|
||||
##############################################################################
|
||||
|
||||
import random
|
||||
import werkzeug
|
||||
from datetime import datetime
|
||||
|
||||
from openerp.addons.web import http
|
||||
from openerp.addons.web.http import request
|
||||
from openerp.tools.translate import _
|
||||
from openerp import SUPERUSER_ID
|
||||
|
||||
import werkzeug
|
||||
import random
|
||||
import json
|
||||
from datetime import datetime
|
||||
import random
|
||||
|
||||
from openerp.tools import html2plaintext
|
||||
import email.utils
|
||||
|
||||
class WebsiteBlog(http.Controller):
|
||||
_blog_post_per_page = 20
|
||||
|
@ -209,13 +205,25 @@ class WebsiteBlog(http.Controller):
|
|||
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']
|
||||
partner_obj = request.registry['res.partner']
|
||||
thread_obj = request.registry['mail.thread']
|
||||
website = request.registry['website']
|
||||
|
||||
public_id = website.get_public_user(cr, uid, context)
|
||||
if uid != public_id:
|
||||
partner_ids = [user.partner_id.id]
|
||||
else:
|
||||
partner_ids = blog_post._find_partner_from_emails(
|
||||
cr, SUPERUSER_ID, 0, [post.get('email')], context=context)
|
||||
if not partner_ids or not partner_ids[0]:
|
||||
partner_ids = [partner_obj.create(cr, SUPERUSER_ID, {'name': post.get('name'), 'email': post.get('email')}, context=context)]
|
||||
|
||||
message_id = blog_post.message_post(
|
||||
cr, SUPERUSER_ID, int(blog_post_id),
|
||||
body=post.get('comment'),
|
||||
type='comment',
|
||||
subtype='mt_comment',
|
||||
email_from = "%s <%s>" % (post.get('name'), post.get('email')),
|
||||
author_id=user.partner_id.id if request.session.uid else False,
|
||||
author_id=partner_ids[0],
|
||||
discussion=post.get('discussion'),
|
||||
context=dict(context, mail_create_nosubcribe=True))
|
||||
return message_id
|
||||
|
@ -237,8 +245,8 @@ class WebsiteBlog(http.Controller):
|
|||
for message in mail_obj.browse(cr, SUPERUSER_ID, ids, context=context):
|
||||
values.append({
|
||||
"id": message.id,
|
||||
"author_name": message.author_id and message.author_id.name or email.utils.parseaddr(message.email_from)[0],
|
||||
"author_image": message.author_id and \
|
||||
"author_name": message.author_id.name,
|
||||
"author_image": message.author_id.image and \
|
||||
("data:image/png;base64,%s" % message.author_id.image) or \
|
||||
'/website_blog/static/src/img/anonymous.png',
|
||||
"date": message.date,
|
||||
|
|
|
@ -101,7 +101,6 @@ class BlogPost(osv.Model):
|
|||
),
|
||||
'visits': fields.integer('No of Views', readonly=True),
|
||||
'ranking': fields.float('Ranking', readonly=True),
|
||||
'author_image': fields.related('create_uid','partner_id', 'image_small', string='Author Photo', type='binary')
|
||||
}
|
||||
_defaults = {
|
||||
'website_published': False,
|
||||
|
|
|
@ -117,7 +117,7 @@
|
|||
<div t-foreach="blog_posts" t-as="blog_post" class="mb32">
|
||||
|
||||
<img class="img-circle pull-right mt16"
|
||||
t-att-src="'/website/image?model=blog.post&field=author_image&id='+str(blog_post.id)"
|
||||
t-att-src="'/website/image?model=res.partner&field=image_small&id='+str(blog_post.create_uid.parnter_id.id)"
|
||||
style="width: 50px;"/>
|
||||
|
||||
<a t-attf-href="/blog/#{ slug(blog_post.blog_id) }/post/#{ slug(blog_post) }">
|
||||
|
@ -182,7 +182,7 @@
|
|||
<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;"/>
|
||||
<img class="img-circle" t-att-src="'/website/image?model=res.partner&field=image_small&id='+str(blog_post.create_uid.partner_id.id)" style="width: 30px; margin-right: 10px;"/>
|
||||
<small id="blog_author" t-field="blog_post.create_uid.name"/><br/>
|
||||
</div>
|
||||
<div t-if="blog_post.content_image" id="blog_angle_down">
|
||||
|
@ -220,7 +220,7 @@
|
|||
<h1 t-field="next_post.name"/>
|
||||
<h2 t-field="next_post.sub_title"/>
|
||||
<div>
|
||||
<img class="img-circle" t-att-src="'/website/image?model=blog.post&field=author_image&id='+str(next_post.id)" style="width: 30px; margin-right: 10px;"/>
|
||||
<img class="img-circle" t-att-src="'/website/image?model=res.partner&field=image_small&id='+str(next_post.create_uid.partner_id.id)" style="width: 30px; margin-right: 10px;"/>
|
||||
<small id="blog_author" t-field="next_post.create_uid.name"/>
|
||||
</div>
|
||||
<p class="mt32">Read Next <span class="fa fa-long-arrow-right"/></p>
|
||||
|
|
|
@ -62,7 +62,6 @@
|
|||
<field name="blog_id"/>
|
||||
</group>
|
||||
<group>
|
||||
<field name="author_image"/>
|
||||
<field name="visits"/>
|
||||
<field name="ranking" invisible="1"/>
|
||||
</group>
|
||||
|
|
Loading…
Reference in New Issue