diff --git a/journals/models.py b/journals/models.py index 8c22374..e8ad133 100755 --- a/journals/models.py +++ b/journals/models.py @@ -406,6 +406,15 @@ 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() @@ -420,6 +429,9 @@ class CourseThemeJ(models.Model): elif actual_lesson != self.actual_lesson.id: self.actual_lesson = Lesson.objects.get(id=self.make_actual_lesson()) + if check_lessons(): + self.success = True + if self.set_open: if self.material._type != 'Ex' and self.actual_lesson and not self.parent.opens.filter( id=CourseMap.objects.get(token=self.actual_lesson.token).id).exists():