[ADD] : change cover photo button , allow to change background image

bzr revid: aja@tinyerp.com-20140213133654-om2eynat2fox473h
This commit is contained in:
ajay javiya (OpenERP) 2014-02-13 19:06:54 +05:30
parent 1235e99646
commit 3168ee3a7f
3 changed files with 35 additions and 1 deletions

View File

@ -303,3 +303,10 @@ class WebsiteBlog(http.Controller):
'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 []

View File

@ -25,7 +25,31 @@
}).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');
}
})();

View File

@ -265,6 +265,9 @@
<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&amp;field=image_small&amp;id='+str(blog_post.create_uid.id)" style="width: 30px; margin-right: 10px;"/>
<small id="blog_author" t-field="blog_post.create_uid.name"/>