From f11d56283666fd319340f8cee14e790800fee273 Mon Sep 17 00:00:00 2001 From: Mikhail Bortnikov Date: Wed, 28 Jun 2017 19:13:28 +0300 Subject: [PATCH] =?UTF-8?q?=D0=9F=D1=80=D0=BE=D0=B2=D0=B5=D1=80=D0=BA?= =?UTF-8?q?=D0=B0=20=D1=83=D1=80=D0=BE=D0=BA=D0=BE=D0=B2=20=D0=BD=D0=B0=20?= =?UTF-8?q?=D1=81=D0=B4=D0=B0=D1=87=D1=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- journals/models.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) 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():