diff options
| author | David Beguin <dbe@odoo.com> | 2019-03-14 17:35:50 +0000 |
|---|---|---|
| committer | David Beguin <dbe@odoo.com> | 2019-03-15 15:05:54 +0000 |
| commit | 5798ca28bfa1dc082fedff5e68ab3f7eb6236687 (patch) | |
| tree | 3de6accf55085fc5c2d46b7227d5f00d5cda5590 /addons/website_slides/static/src/js | |
| parent | d4db21a9cc89bc09acb64f8743bf12df910abc96 (diff) | |
[IMP] website_slides : improve get slide access computation
As slides are returned in sudo to the template, the user rights were
checked via a can_access variable set in the template directly.
In order to disable the vote for user that cannot get access to the course
all the checks are now done in backend (also to avoid to get access to slides
in sudo mode with rpc calls). We add now, for each slide on the course view,
the access and vote rights to the template : can_access and can_vote.
Those two are computed in backend, using the user's access right instead of admin's.
But, as if the user is not member of the channel, he cannot get access to the
course slides (expect for Free Peview ones), so the check on can_vote
will crash. This is why we check the access rights before checking can_vote,
for each slides (as free preview slides are still accessible,
even if the user is not in channel members).
The vote widget is disabled if user's can_access or can_vote = False, enabled otherwise.
If user have access but have not enough karma, the controller will handle this
case and return an error to the user telling him he has not enough karma to vote.
If user can vote but cannot access, the controller will handle this
case and return an error to the user telling him he has no access to the lesson.
Task ID: 1943788
PR #31321
Diffstat (limited to 'addons/website_slides/static/src/js')
| -rw-r--r-- | addons/website_slides/static/src/js/slides_slide_like.js | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/addons/website_slides/static/src/js/slides_slide_like.js b/addons/website_slides/static/src/js/slides_slide_like.js index bb0542a5f7e..6609cc0ca92 100644 --- a/addons/website_slides/static/src/js/slides_slide_like.js +++ b/addons/website_slides/static/src/js/slides_slide_like.js @@ -56,9 +56,11 @@ var SlideLikeWidget = Widget.extend({ self.$el.find('span.o_wslides_js_slide_like_down span').text(data.dislikes); } else { if (data.error === 'public_user') { - self._popoverAlert(self.$el, _.str.sprintf(_t('Please <a href="/web/login?redirect=%s">login</a> to vote this slide'), (document.URL))); + self._popoverAlert(self.$el, _.str.sprintf(_t('Please <a href="/web/login?redirect=%s">login</a> to vote this lesson'), (document.URL))); } else if (data.error === 'vote_done') { - self._popoverAlert(self.$el, _t('You have already voted for this slide')); + self._popoverAlert(self.$el, _t('You have already voted for this lesson')); + } else if (data.error === 'slide_access') { + self._popoverAlert(self.$el, _t('You don\'t have access to this lesson')); } else if (data.error === 'comment_disabled') { self._popoverAlert(self.$el, _t('Votes and comments are disabled for this channel')); } else if (data.error === 'missing_karma') { |
