+ 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
+