Skip to content
Permalink
Browse files

[FIX] website_slides: set slide as completed only for valid members

Indeed some slides are available for external people if is_preview is set
to True. It indicates slide is available for teasing. It should not be
marked as completed for non members.

This commit is linked to task ID 1942836 and PR #31239.

Co-Authored-By: Aurélien Warnon <awa@odoo.com>
Co-Authored-By: Thibault Delavallée <tde@odoo.com>
  • Loading branch information...
tde-banana-odoo and awa-odoo committed Feb 19, 2019
1 parent 4f380f4 commit 49a005bbd1ecc85103005f63de2aa9bd28ebfe0b
Showing with 12 additions and 8 deletions.
  1. +12 −8 addons/website_slides/controllers/main.py
@@ -47,10 +47,15 @@ def _set_viewed_slide(self, slide):
slide.action_set_viewed()
return True

def _set_completed_slide(self, slide):
if slide.website_published and slide.channel_id.is_member:
slide.action_set_completed()
return True

def _get_slide_detail(self, slide):
most_viewed_slides = slide.get_most_viewed_slides(self._slides_per_list)
related_slides = slide.get_related_slides(self._slides_per_list)
values = {
values = {
'slide': slide,
'most_viewed_slides': most_viewed_slides,
'related_slides': related_slides,
@@ -477,20 +482,19 @@ def submit_quiz(self, slide_id, answer_ids,**kw):
'error': "You already passed this quiz"
}

#SLIDE STATE CONTROLLERS
# SLIDE STATE CONTROLLERS
# TDE CLEANME: clean ctrlr / method name

@http.route('/slide/completed/<int:slide_id>', website=True, type="http", auth="user")
def mark_as_completed(self, slide_id, next_slide=None, **kw):
def mark_as_completed(self, slide_id, next_slide=None):
slide = request.env['slide.slide'].browse(slide_id)
slide.action_set_completed()
self._set_completed_slide(slide)
return werkzeug.utils.redirect("/slides/slide/%s" %(next_slide))


@http.route('/slides/set_completed', website=True, type="json", auth="user")
def set_status_as_done(self, slide_id, **kw):
def set_status_as_done(self, slide_id):
slide = request.env['slide.slide'].browse(slide_id)
slide.channel_id.invalidate_cache()
slide.action_set_completed()
self._set_completed_slide(slide)
return {
'channel_completion': slide.channel_id.completion
}

0 comments on commit 49a005b

Please sign in to comment.
You can’t perform that action at this time.