From ceb99a32b9a2be423a530f3650a2ba6179d42f91 Mon Sep 17 00:00:00 2001
From: Juliana <juliana@le-filament.com>
Date: Wed, 23 Jun 2021 18:15:07 +0200
Subject: [PATCH] [ADD] Add notif to answers done + send mail when answers done

---
 controllers/main.py               |  5 +++
 models/survey_survey.py           |  9 +----
 static/src/css/ethikis_survey.css | 60 +++++++++++++++++++++++++++++--
 3 files changed, 63 insertions(+), 11 deletions(-)

diff --git a/controllers/main.py b/controllers/main.py
index 87f423e..dea8556 100644
--- a/controllers/main.py
+++ b/controllers/main.py
@@ -49,6 +49,11 @@ class WebsiteSurveyExtend(Survey):
             vals = {'last_displayed_page_id': page_id}
             if next_page is None and not go_back:
                 vals.update({'state': 'done'})
+                if user_input.survey_id.is_mail_auto:
+                    # Send mail auto if survey configurated
+                    user_input.action_send_mail()
+                # Send notification to followers
+                survey.message_post(body="Sondage terminé", message_type="notification", subtype="ethikis_survey.survey_state_change")
             else:
                 vals.update({'state': 'skip'})
             user_input.sudo(user=user_id).write(vals)
diff --git a/models/survey_survey.py b/models/survey_survey.py
index ea888f2..c7fb9ad 100644
--- a/models/survey_survey.py
+++ b/models/survey_survey.py
@@ -38,7 +38,7 @@ class Survey(models.Model):
 
     def _track_subtype(self, init_values):
         self.ensure_one()
-        if (('stage_id' in init_values) and (self.stage_id.name == "Fermé")):
+        if (('stage_id' in init_values) and (self.stage_id.name == "Terminé")):
             return 'ethikis_survey.survey_state_change'
         return super(Survey, self)._track_subtype(init_values)
 
@@ -92,13 +92,6 @@ class SurveyUserInput(models.Model):
                 'url': '/survey/%s/%s/%s' % (url_tag, self.survey_id.id, self.token)
             }
 
-    @api.onchange('state')
-    def on_change_state(self):
-        # At the end of the survey, send a mail if survey is configured for that
-        if self.state == 'done':
-            if self.survey_id.is_mail_auto:
-                self.action_send_mail()
-
     @api.multi
     def action_send_mail(self):
         self.ensure_one()
diff --git a/static/src/css/ethikis_survey.css b/static/src/css/ethikis_survey.css
index 8b3c80d..676eb1f 100644
--- a/static/src/css/ethikis_survey.css
+++ b/static/src/css/ethikis_survey.css
@@ -185,14 +185,57 @@ input[type=range] {
 input[type=range]:focus {
   outline: none;
 }
+
+input[type=range]::-ms-track {
+  width: 100%;
+  height: 4px;
+  cursor: pointer;
+  animate: 0.2s;
+  background: #61C4E1;
+  background-color: #61C4E1;
+  border-radius: 25px;
+}
+
+input[type=range]::-moz-range-track {
+  width: 100%;
+  height: 4px;
+  cursor: pointer;
+  animate: 0.2s;
+  background: #61C4E1;
+  background-color: #61C4E1;
+  border-radius: 25px;
+}
+
 input[type=range]::-webkit-slider-runnable-track {
   width: 100%;
   height: 4px;
   cursor: pointer;
   animate: 0.2s;
   background: #61C4E1;
+  background-color: #61C4E1;
   border-radius: 25px;
 }
+
+input[type=range]::-moz-range-thumb{
+  height: 20px;
+  width: 20px;
+  border-radius: 50%;
+  background: #fff;
+  box-shadow: 0 0 4px 0 rgba(0,0,0, 1);
+  cursor: pointer;
+  -webkit-appearance: none;
+  margin-top: -8px;
+}
+input[type=range]::-ms-thumb{
+  height: 20px;
+  width: 20px;
+  border-radius: 50%;
+  background: #fff;
+  box-shadow: 0 0 4px 0 rgba(0,0,0, 1);
+  cursor: pointer;
+  -webkit-appearance: none;
+  margin-top: -8px;
+}
 input[type=range]::-webkit-slider-thumb {
   height: 20px;
   width: 20px;
@@ -203,9 +246,20 @@ input[type=range]::-webkit-slider-thumb {
   -webkit-appearance: none;
   margin-top: -8px;
 }
+
+input[type=range]:focus::-ms-track{
+  background:  #61C4E1;
+  background-color: #61C4E1;
+}
+input[type=range]:focus::-moz-range-track{
+  background:  #61C4E1;
+  background-color: #61C4E1;
+}
 input[type=range]:focus::-webkit-slider-runnable-track {
   background:  #61C4E1;
+  background-color: #61C4E1;
 }
+
 .range-wrap{
   position: relative;
 }
@@ -246,7 +300,7 @@ input[type=range]:focus::-webkit-slider-runnable-track {
     box-shadow: 0 0 0 0.2rem rgba(0, 160, 157, 0);
 }
 
-.form-control {
-    background-color: transparent !important;
-    border: 0px solid #ced4da !important;
+input#range{
+  background-color: transparent !important;
+  border: 0px solid #ced4da !important;
 }
-- 
GitLab