From: Guillaume Pellerin Date: Fri, 11 Jul 2014 09:41:33 +0000 (+0200) Subject: fix no weight X-Git-Tag: 2.8.1-pro~282^2~171^2 X-Git-Url: https://git.parisson.com/?a=commitdiff_plain;h=df3e0bbed5824ffae272d13de517b91eca6df3e8;p=teleforma.git fix no weight --- diff --git a/teleforma/context_processors.py b/teleforma/context_processors.py index bd9d5767..49edb4c7 100644 --- a/teleforma/context_processors.py +++ b/teleforma/context_processors.py @@ -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)