From 7276c049867c5002199692b27850982293005e5d Mon Sep 17 00:00:00 2001 From: Jan Szejko Date: Thu, 25 Aug 2016 11:53:47 +0200 Subject: [PATCH] fix publish with no attachments --- apps/catalogue/models/book.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/apps/catalogue/models/book.py b/apps/catalogue/models/book.py index 4c35e689..45726551 100755 --- a/apps/catalogue/models/book.py +++ b/apps/catalogue/models/book.py @@ -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) -- 2.20.1