From 039df4a79e27867e216cf48d28274f3ea3d7fdfc Mon Sep 17 00:00:00 2001 From: jem-odoo Date: Wed, 20 Feb 2019 09:10:07 +0000 Subject: [PATCH] [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. --- addons/website_slides/controllers/main.py | 2 +- addons/website_slides/static/src/js/slides_like.js | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/addons/website_slides/controllers/main.py b/addons/website_slides/controllers/main.py index ea7da51046c..7ab6b6052d7 100644 --- a/addons/website_slides/controllers/main.py +++ b/addons/website_slides/controllers/main.py @@ -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'} diff --git a/addons/website_slides/static/src/js/slides_like.js b/addons/website_slides/static/src/js/slides_like.js index 589ca6fefda..f0589373cb9 100644 --- a/addons/website_slides/static/src/js/slides_like.js +++ b/addons/website_slides/static/src/js/slides_like.js @@ -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); }, });