X-Git-Url: https://git.mdrn.pl/wolnelektury.git/blobdiff_plain/7e6d14043e3e2dce8e3fdcef0b0fc649680b07b3..7b49c1a8c8a2c7634342ebcacb5520f8e243fda4:/apps/catalogue/models.py?ds=sidebyside diff --git a/apps/catalogue/models.py b/apps/catalogue/models.py index 2ca78b01e..12b394d00 100644 --- a/apps/catalogue/models.py +++ b/apps/catalogue/models.py @@ -202,8 +202,10 @@ def get_customized_pdf_path(book, customizations): """ 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 @@ -479,7 +481,7 @@ class Book(models.Model): formats = [] # files generated during publication if self.has_media("html"): - formats.append(u'%s' % (reverse('book_text', [self.fileid()]), _('Read online'))) + formats.append(u'%s' % (reverse('book_text', args=[self.fileid()]), _('Read online'))) if self.has_media("pdf"): formats.append(u'PDF' % self.get_media('pdf').url) if self.has_media("mobi"): @@ -565,16 +567,17 @@ class Book(models.Model): 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.