X-Git-Url: https://git.mdrn.pl/redakcja.git/blobdiff_plain/132297f0be27da544304733bd24da32282310235..2dffd92a117a4f551b10f059786825ff19838d8e:/apps/catalogue/models/book.py diff --git a/apps/catalogue/models/book.py b/apps/catalogue/models/book.py index 83db3057..45726551 100755 --- a/apps/catalogue/models/book.py +++ b/apps/catalogue/models/book.py @@ -137,7 +137,7 @@ class Book(models.Model): return instance def make_chunk_slug(self, proposed): - """ + """ Finds a chunk slug not yet used in the book. """ slugs = set(c.slug for c in self) @@ -200,10 +200,10 @@ class Book(models.Model): # and move the gallery starts if gm.was_merged: - for chunk in self[len(self) - len_other:]: - old_start = chunk.gallery_start or 1 - chunk.gallery_start = old_start + gm.dest_size - gm.num_deleted - chunk.save() + for chunk in self[len(self) - len_other:]: + old_start = chunk.gallery_start or 1 + chunk.gallery_start = old_start + gm.dest_size - gm.num_deleted + chunk.save() other.delete() @@ -365,10 +365,10 @@ class Book(models.Model): def refresh(self): """This should be done offline.""" - self.short_html() - self.single() - self.new_publishable() - self.published() + self.short_html + self.single + self.new_publishable + self.published # Materializing & publishing # ========================== @@ -388,7 +388,7 @@ class Book(models.Model): return changes def materialize(self, publishable=False, changes=None): - """ + """ Get full text of the document compiled from chunks. Takes the current versions of all texts or versions most recently tagged for publishing, @@ -423,7 +423,10 @@ class Book(models.Model): gallery_dir = os.path.join(settings.MEDIA_ROOT, settings.IMAGE_DIR, self.slug) if os.path.isdir(gallery_dir): data['gallery_url'] = gallery_url - data['attachments'] = json.dumps(os.listdir(gallery_dir)) + attachments = os.listdir(gallery_dir) + else: + attachments = [] + data['attachments'] = json.dumps(attachments) apiclient.api_call(user, "lessons/", data) # record the publish br = BookPublishRecord.objects.create(book=self, user=user)