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():