X-Git-Url: https://git.mdrn.pl/edumed.git/blobdiff_plain/a1fc6bb1bbb481ba116d8873ffd7cb3f4f0a6488..a03fd84930ff74ec7280e380d9c5cf703dfa60ba:/catalogue/models.py diff --git a/catalogue/models.py b/catalogue/models.py index 3ae4490..239f60c 100644 --- a/catalogue/models.py +++ b/catalogue/models.py @@ -11,6 +11,8 @@ class Section(models.Model): order = models.IntegerField() xml_file = models.FileField(upload_to="catalogue/section/xml", null=True, blank=True, max_length=255) + image = models.ImageField(upload_to="catalogue/section/image", + null=True, blank=True) class Meta: ordering = ['order'] @@ -122,9 +124,10 @@ class Lesson(models.Model): lesson.populate_dc() lesson.build_html(infile=infile) lesson.build_pdf(infile=infile) - lesson.build_pdf(student=True, infile=infile) lesson.build_package() - lesson.build_package(student=True) + if lesson.type != 'project': + lesson.build_pdf(student=True, infile=infile) + lesson.build_package(student=True) return lesson def populate_dc(self): @@ -176,17 +179,15 @@ class Lesson(models.Model): File(open(pdf.get_filename()))) def add_to_zip(self, zipf, student=False, prefix=''): - zipf.write(self.xml_file.path, - "%spliki-zrodlowe/%s.xml" % (prefix, self.slug)) pdf = self.student_pdf if student else self.pdf if pdf: zipf.write(pdf.path, "%s%s%s.pdf" % (prefix, self.slug, "_student" if student else "")) - for attachment in self.attachment_set.all(): - zipf.write(attachment.file.path, - u"%smaterialy/%s.%s" % (prefix, attachment.slug, attachment.ext)) - - + for attachment in self.attachment_set.all(): + zipf.write(attachment.file.path, + u"%smaterialy/%s.%s" % (prefix, attachment.slug, attachment.ext)) + zipf.write(self.xml_file.path, + "%spliki-zrodlowe/%s.xml" % (prefix, self.slug)) def build_package(self, student=False): from StringIO import StringIO