"""
customizations.sort()
h = hash(tuple(customizations))
+
pdf_name = '%s-custom-%s' % (book.fileid(), h)
- pdf_file = models.get_dynamic_path(None, pdf_name, ext='pdf')
+ pdf_file = get_dynamic_path(None, pdf_name, ext='pdf')
+
return pdf_file
formats = []
# files generated during publication
if self.has_media("html"):
- formats.append(u'<a href="%s">%s</a>' % (reverse('book_text', [self.fileid()]), _('Read online')))
+ formats.append(u'<a href="%s">%s</a>' % (reverse('book_text', args=[self.fileid()]), _('Read online')))
if self.has_media("pdf"):
formats.append(u'<a href="%s">PDF</a>' % self.get_media('pdf').url)
if self.has_media("mobi"):
cache.set(cache_key, short_html, CACHE_FOREVER)
return mark_safe(short_html)
+ def mini_box(self):
+ if self.id:
+ cache_key = "Book.mini_boxs/%d" % (self.id, )
+ short_html = cache.get(cache_key)
+ else:
+ short_html = None
+
+ if short_html is None:
+ authors = self.tags.filter(category='author')
+
+ short_html = unicode(render_to_string('catalogue/book_mini_box.html',
+ {'book': self, 'authors': authors, 'STATIC_URL': settings.STATIC_URL}))
+
+ if self.id:
+ cache.set(cache_key, short_html, CACHE_FOREVER)
+ return mark_safe(short_html)
+
@property
def root_ancestor(self):
""" returns the oldest ancestor """
current_self.pdf_file.save('%s.pdf' % self.fileid(),
File(open(pdf.get_filename())))
self.pdf_file = current_self.pdf_file
+
+ # remove cached downloadables
+ remove_zip(settings.ALL_PDF_ZIP)
+
+ for customized_pdf in get_existing_customized_pdf(self):
+ unlink(customized_pdf)
else:
print "saving %s" % file_name
print "to: %s" % DefaultStorage().path(file_name)
DefaultStorage().save(file_name, File(open(pdf.get_filename())))
- # remove cached downloadables
- remove_zip(settings.ALL_PDF_ZIP)
- for customized_pdf in get_existing_customized_pdf(self):
- unlink(customized_pdf)
-
def build_mobi(self):
""" (Re)builds the MOBI file.