+ def build_pdf(self, student=False):
+ from .publish import PdfFormat
+ # PDF uses document with attachments already saved as media,
+ # otherwise sorl.thumbnail complains about SuspiciousOperations.
+ wldoc = self.wldocument()
+ if student:
+ pdf = PdfFormat(wldoc).build()
+ self.student_pdf.save("%s.pdf" % self.slug,
+ File(open(pdf.get_filename())))
+ else:
+ pdf = PdfFormat(wldoc, teacher=True).build()
+ self.pdf.save("%s.pdf" % self.slug,
+ File(open(pdf.get_filename())))
+