gallery = models.CharField(_('scan gallery name'), max_length=255, blank=True)
project = models.ForeignKey(Project, null=True)
- #wl_slug = models.CharField(_('title'), max_length=255, null=True, db_index=True, editable=False)
- parent = models.ForeignKey('self', null=True, blank=True, verbose_name=_('parent'), related_name="children", editable=False)
+ # wl_slug = models.CharField(_('title'), max_length=255, null=True, db_index=True, editable=False)
+ parent = models.ForeignKey(
+ 'self', null=True, blank=True, verbose_name=_('parent'), related_name="children", editable=False)
parent_number = models.IntegerField(_('parent number'), null=True, blank=True, db_index=True, editable=False)
# Cache
verbose_name = _('book')
verbose_name_plural = _('books')
-
# Representing
# ============
@models.permalink
def get_absolute_url(self):
- return ("catalogue_book", [self.slug])
+ return "catalogue_book", [self.slug]
+
+ def gallery_path(self):
+ return os.path.join(settings.MEDIA_ROOT, settings.IMAGE_DIR, self.gallery)
def correct_about(self):
return "http://%s%s" % (
# TODO: move to celery
doc = book.wldocument()
# TODO: error handling
- pdf_file = doc.as_pdf(cover=True, ilustr_path=os.path.join(settings.MEDIA_ROOT, settings.IMAGE_DIR, book.gallery))
+ pdf_file = doc.as_pdf(cover=True, ilustr_path=book.gallery_path())
from catalogue.ebook_utils import serve_file
return serve_file(pdf_file.get_filename(),
book.slug + '.pdf', 'application/pdf')
# TODO: move to celery
doc = book.wldocument()
# TODO: error handling
- epub = doc.as_epub().get_string()
+ epub = doc.as_epub(ilustr_path=book.gallery_path()).get_string()
response = HttpResponse(mimetype='application/epub+zip')
response['Content-Disposition'] = 'attachment; filename=%s' % book.slug + '.epub'
response.write(epub)