+ courses = set()
+ for identifier in wldoc.book_info.curriculum:
+ identifier = (identifier or "").replace(' ', '')
+ if not identifier: continue
+ try:
+ curr = Curriculum.objects.get(identifier__iexact=identifier)
+ except Curriculum.DoesNotExist:
+ logging.warn('Unknown curriculum course %s in lesson %s' % (identifier, self.slug))
+ pass
+ else:
+ courses.add(curr.course)
+ self.curriculum_courses = courses
+
+ def populate_description(self, wldoc=None, infile=None):
+ if wldoc is None:
+ wldoc = self.wldocument(infile)
+ for nagl in wldoc.edoc.findall('.//naglowek_rozdzial'):
+ if (nagl.text or '').strip() == u'Pomysł na lekcję':
+ from lxml import etree
+ self.description = etree.tostring(nagl.getnext(),
+ method='text', encoding='unicode').strip()
+ self.save()
+ return
+
+ def wldocument(self, infile=None):
+ from librarian import IOFile