'author_image': "data:image/png;base64,%s" % post.author_id.image,
})
return values
+
+ @http.route('/blogpsot/change_background', type='json', auth="public", website=True)
+ def bg_change(self, post_id=0,image=None, **post):
+ post_obj = request.registry.get('blog.post')
+ values = {'content_image' : image}
+ ids = post_obj.write(request.cr, SUPERUSER_ID, [int(post_id)], values)
+ return []
}).then(function (cat_id) {
document.location = '/blogpost/new?blog_id=' + cat_id;
});
- }
+ },
}),
+ edit: function () {
+ var res = this._super();
+ $('body').on('click', '#change_cover',change_bg);
+ return res;
+ },
+ save : function() {
+ openerp.jsonRpc("/blogpsot/change_background", 'call', {
+ 'post_id' : $('#blog_post_name').attr('data-oe-id'),
+ 'image' : $('.blog_cover')[0].style.background.replace('url(','').replace(')',''),
+ });
+ return this._super();
+ },
});
+
+ function change_bg(ev){
+ var self = this;
+ var editor = new website.editor.ImageDialog();
+ editor.on('start', self, function (o) {
+ o.url = $(self).parent()[0].style.background.replace('url(','').replace(')','');
+ });
+ editor.on('save', self, function (o) {
+ $(self).parent().css("background-image", o.url && o.url !== "" ? 'url(' + o.url + ')' : "");
+ });
+ editor.appendTo('body');
+ }
})();
<h2 class="text-center " t-field="blog_post.sub_title"/>
</xpath>
<xpath expr="//div[@id='title']" position="inside">
+ <a t-ignore="true" id="change_cover" class="btn btn-primary hover-edition-button css_non_editable_mode_hidden" style="top: 533px; left: 648px; cursor :pointer">
+ Change Cover Photo
+ </a>
<div class="text-center blog_item">
<img class="img-circle" t-att-src="'/website/image?model=res.users&field=image_small&id='+str(blog_post.create_uid.id)" style="width: 30px; margin-right: 10px;"/>
<small id="blog_author" t-field="blog_post.create_uid.name"/>