+ def get_other_level(self):
+ if self.section is None: return None
+ other_levels = self.section.lesson_set.exclude(level=self.level)
+ if other_levels.exists():
+ return other_levels[0].level
+
+ def get_previous(self):
+ if self.section is None: return None
+ try:
+ return self.section.lesson_set.filter(
+ type=self.type, level=self.level,
+ order__lt=self.order).order_by('-order')[0]
+ except IndexError:
+ return None
+
+ def get_next(self):
+ if self.section is None: return None
+ try:
+ return self.section.lesson_set.filter(
+ type=self.type, level=self.level,
+ order__gt=self.order).order_by('order')[0]
+ except IndexError:
+ return None
+