[FIX] website_slides: fix vote widget

Fix route of vote widget. Set it to auth=public so that instead of a crash
we have correct popup asking to login. Better than a SessionException, which
will not be displayed.

Another fix is done to avoid having one widget for all displayed like / dislike
buttons. Each slide should have its own vote widget.

Commit linked to task ID 1941250 and PR #31317.
This commit is contained in:
jem-odoo
2019-02-21 16:39:56 +00:00
committed by Thibault Delavallée
parent fdc36c5c37
commit 039df4a79e
2 changed files with 5 additions and 2 deletions
+1 -1
View File
@@ -538,7 +538,7 @@ class WebsiteSlides(WebsiteProfile):
}
# JSONRPC
@http.route('/slides/slide/like', type='json', auth="user", website=True)
@http.route('/slides/slide/like', type='json', auth="public", website=True)
def slide_like(self, slide_id, upvote):
if request.website.is_public_user():
return {'error': 'public_user'}
@@ -86,8 +86,11 @@ sAnimations.registry.websiteSlidesLike = sAnimations.Class.extend({
* @param {Object} parent
*/
start: function () {
var self = this;
var defs = [this._super.apply(this, arguments)];
defs.push(new LikeButton(this).attachTo($('.o_wslides_like')));
$('.o_wslides_like').each(function () {
defs.push(new LikeButton(self).attachTo($(this)));
});
return $.when.apply($, defs);
},
});