From 954e8ca6d49b12b2ae72e195c4d7746bafa3434d Mon Sep 17 00:00:00 2001
From: jem-odoo <jem@openerp.com>
Date: Thu, 14 Mar 2019 16:24:18 +0000
Subject: [PATCH] [FIX] website_slides: prevent to mark a certification as done

When a certification slide is display in no fullscreen
mode, the done button is clickable. Same applies to quiz
slide.
This commit prevents user to manually mark a slide as done
for slide type that requires an other action (submit answer,
pass survey, ...).

Task-1941250
---
 .../views/website_slides_templates_lesson.xml              | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/addons/website_slides/views/website_slides_templates_lesson.xml b/addons/website_slides/views/website_slides_templates_lesson.xml
index c7f1cd8a7e19..89457ed8de76 100644
--- a/addons/website_slides/views/website_slides_templates_lesson.xml
+++ b/addons/website_slides/views/website_slides_templates_lesson.xml
@@ -191,9 +191,10 @@
                     t-att-href="'/slides/slide/%s' % (slug(previous_slide)) if previous_slide else '#'">
                     <i class="fa fa-chevron-left mr-2"></i> Prev
                 </a>
-                <a t-att-class="'btn btn-primary border text-white %s' % ('disabled' if slide.question_ids or channel_progress[slide.id].get('completed') else '')"
-                    role="button" t-att-aria-disabled="'true' if slide.question_ids or channel_progress[slide.id].get('completed') else None"
-                    t-att-href="'#' if slide.question_ids or channel_progress[slide.id].get('completed') else '/slides/slide/%s/set_completed?%s' % (slide.id, 'next_slide_id=%s' % (next_slide.id) if next_slide else '')">
+                <t t-set="allow_done_btn" t-value="slide.slide_type in ['infographic', 'presentation', 'document', 'webpage'] and not slide.question_ids and not channel_progress[slide.id].get('completed')"/>
+                <a t-att-class="'btn btn-primary border text-white %s' % ('disabled' if not allow_done_btn else '')"
+                    role="button" t-att-aria-disabled="'true' if not allow_done_btn else None"
+                    t-att-href="'/slides/slide/%s/set_completed?%s' % (slide.id, 'next_slide_id=%s' % (next_slide.id) if next_slide else '') if allow_done_btn else '#'">
                     Set Done
                 </a>
                 <a t-att-class="'btn btn-light border %s' % ('disabled' if not next_slide else '')"
-- 
GitLab