]> git.parisson.com Git - teleforma.git/commitdiff
fix no weight
authorGuillaume Pellerin <yomguy@parisson.com>
Fri, 11 Jul 2014 09:41:33 +0000 (11:41 +0200)
committerGuillaume Pellerin <yomguy@parisson.com>
Fri, 11 Jul 2014 09:41:33 +0000 (11:41 +0200)
teleforma/context_processors.py

index bd9d57679f01489572a4c1249b59055cde19a106..49edb4c749bc937eb447b1203ce434e150941ba9 100644 (file)
@@ -46,17 +46,19 @@ def seminar_progress(user, seminar):
     objects = [seminar.docs_1, seminar.docs_2, seminar.medias, seminar.docs_correct]
     for obj in objects:
         for item in obj.all():
-            total += item.weight
-            if user in item.readers.all():
-                progress += item.weight
+            if item.weight:
+                total += item.weight
+                if user in item.readers.all():
+                    progress += item.weight
 
     questions = Question.objects.filter(seminar=seminar, status=3)
     for question in questions:
-        total += question.weight
-        answer = Answer.objects.filter(question=question, status=3, user=user, 
-                                        validated=True, treated=True)
-        if answer:
-            progress += question.weight
+        if question.weight:
+            total += question.weight
+            answer = Answer.objects.filter(question=question, status=3, user=user,
+                                            validated=True, treated=True)
+            if answer:
+                progress += question.weight
 
     if total != 0:
         return int(progress*100/total)