[IMP] website_blog: raw html from python to data
Using message_post_with_view, raw html contained in python is now moved into a template data and called from the code. This allows to avoid having raw html directly embedded in python code.
This commit is contained in:
@@ -213,17 +213,12 @@ class BlogPost(osv.Model):
|
||||
|
||||
def _check_for_publication(self, cr, uid, ids, vals, context=None):
|
||||
if vals.get('website_published'):
|
||||
base_url = self.pool['ir.config_parameter'].get_param(cr, uid, 'web.base.url')
|
||||
for post in self.browse(cr, uid, ids, context=context):
|
||||
post.blog_id.message_post(
|
||||
body='<p>%(post_publication)s <a href="%(base_url)s/blog/%(blog_slug)s/post/%(post_slug)s">%(post_link)s</a></p>' % {
|
||||
'post_publication': _('A new post %s has been published on the %s blog.') % (post.name, post.blog_id.name),
|
||||
'post_link': _('Click here to access the post.'),
|
||||
'base_url': base_url,
|
||||
'blog_slug': slug(post.blog_id),
|
||||
'post_slug': slug(post),
|
||||
},
|
||||
subtype='website_blog.mt_blog_blog_published')
|
||||
post.blog_id.message_post_with_view(
|
||||
'website_blog.blog_post_template_new_post',
|
||||
subject=post.name,
|
||||
values={'post': post},
|
||||
subtype_id=self.pool['ir.model.data'].xmlid_to_res_id(cr, SUPERUSER_ID, 'website_blog.mt_blog_blog_published'))
|
||||
return True
|
||||
return False
|
||||
|
||||
|
||||
@@ -481,5 +481,16 @@
|
||||
</feed>
|
||||
</template>
|
||||
|
||||
<!-- Chatter templates -->
|
||||
<template id="blog_post_template_new_post">
|
||||
<p>A new post <t t-esc="post.name" /> has been published on the <t t-esc="object.name" /> blog. Click here to access the blog :</p>
|
||||
<p style="margin-left: 30px; margin-top: 10 px; margin-bottom: 10px;">
|
||||
<a href="/blog/#{slug(object)}/post/#{slug(post)}"
|
||||
style="padding: 5px 10px; font-size: 12px; line-height: 18px; color: #FFFFFF; border-color:#a24689; text-decoration: none; display: inline-block; margin-bottom: 0px; font-weight: 400; text-align: center; vertical-align: middle; cursor: pointer;background-color: #a24689; border: 1px solid #a24689; border-radius:3px">
|
||||
Access post
|
||||
</a>
|
||||
</p>
|
||||
</template>
|
||||
|
||||
</data>
|
||||
</openerp>
|
||||
|
||||
Reference in New Issue
Block a user