From 2ec13c680d1a73f192eb5fda2913c9b68fd93289 Mon Sep 17 00:00:00 2001 From: Guillaume Pellerin Date: Mon, 20 Jul 2015 15:47:46 +0200 Subject: [PATCH] fix rejected copies --- teleforma/exam/views.py | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/teleforma/exam/views.py b/teleforma/exam/views.py index 0cf9cc0f..de320f54 100644 --- a/teleforma/exam/views.py +++ b/teleforma/exam/views.py @@ -131,14 +131,16 @@ class ScriptsRejectedView(ScriptsView): def get_queryset(self): user = self.request.user period = Period.objects.get(id=self.kwargs['period_id']) - if user.professor.all(): - Q1 = Q(status=0) - scripts = Script.objects.filter(Q1) - else: - Q1 = Q(status=0, author=user) - Q2 = Q(status=0, corrector=user) - scripts = Script.objects.filter(Q1 | Q2) - return scripts + QT = Q(status=0, author=user) + QT = Q(status=0, corrector=user) | QT + + professor = user.professor.all() + if professor: + professor = professor[0] + for course in professor.courses.all(): + QT = Q(status=0, period=period, course=course) | QT + + return Script.objects.filter(QT) def get_context_data(self, **kwargs): context = super(ScriptsRejectedView, self).get_context_data(**kwargs) -- 2.39.5