+ 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)
+ if self.type == 'project':
+ lookup = u'Zadanie'
+ else:
+ lookup = u'Pomysł na lekcję'
+ for header in wldoc.edoc.findall('.//naglowek_rozdzial'):
+ if (header.text or '').strip() == lookup:
+ from lxml import etree
+ self.description = etree.tostring(header.getnext(),
+ method='text', encoding='unicode').strip()
+ self.save()
+ return
+
+ def wldocument(self, infile=None):
+ from librarian import IOFile