merge new librarian changes with custom pdf fix
authorMarcin Koziej <marcin.koziej@nowoczesnapolska.org.pl>
Mon, 12 Dec 2011 08:18:49 +0000 (09:18 +0100)
committerMarcin Koziej <marcin.koziej@nowoczesnapolska.org.pl>
Mon, 12 Dec 2011 08:18:49 +0000 (09:18 +0100)
apps/catalogue/models.py

index 2ca78b0..afc241d 100644 (file)
@@ -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
 
 
@@ -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.