+ section = cls.objects.get(slug=slug)
+ except cls.DoesNotExist:
+ section = cls(slug=slug, order=0)
+
+ # Save XML file
+ section.xml_file.save('%s.xml' % slug, ContentFile(xml), save=False)
+ section.title = wldoc.book_info.title
+ section.save()
+
+ section.lesson_set.all().update(section=None)
+ for i, lesson in enumerate(lessons):
+ lesson.section = section
+ lesson.order = i
+ lesson.save()
+
+ return section
+
+ def syntetic_lesson(self, level):
+ try:
+ return self.lesson_set.filter(type='synthetic', level=level)[0]