From 21ba623e4151fc5b7f8e72c15117c9e6d558977a Mon Sep 17 00:00:00 2001 From: Mikhail Bortnikov Date: Tue, 11 Jul 2017 17:03:25 +0300 Subject: [PATCH] =?UTF-8?q?=D0=9F=D0=BE=D0=BC=D0=B5=D0=BD=D1=8F=D0=BB=20?= =?UTF-8?q?=D0=BF=D1=80=D0=BE=D0=B2=D0=B5=D1=80=D0=BA=D1=83=20=D1=83=D1=80?= =?UTF-8?q?=D0=BE=D0=BA=D0=BE=D0=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- journals/models.py | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/journals/models.py b/journals/models.py index 152c1c9..d37b418 100755 --- a/journals/models.py +++ b/journals/models.py @@ -414,15 +414,6 @@ class CourseThemeJ(models.Model): p.save() return p - def check_lessons(self): - """ Проверка уроков темы на статус. Если сдано - сдана тема""" - for lessonj in LessonJ.objects.filter(parent=self, student=self.student): - if lessonj.success == False: - return False - - return True - - def save(self, *args, **kwargs): if not self.parent: self.parent = self.get_parent() @@ -437,8 +428,11 @@ class CourseThemeJ(models.Model): elif actual_lesson != self.actual_lesson.id: self.actual_lesson = Lesson.objects.get(id=self.make_actual_lesson()) - if self.check_lessons(): - self.success = True + if LessonJ.objects.filter(parent=self, student=self.student).exists(): + if LessonJ.objects.filter(parent=self, student=self.student, success=False).exists(): + self.success = False + else: + self.success = True if self.set_open: if Lesson.objects.filter(theme=self.material).order_by('sort').exists():