X-Git-Url: https://git.mdrn.pl/redakcja.git/blobdiff_plain/4184843909d3867e3f9d8d489fea78377794cad1..a802a933f53625f732e9d3807b4162e770c8aaf1:/apps/catalogue/models/book.py diff --git a/apps/catalogue/models/book.py b/apps/catalogue/models/book.py index c8792bbf..d8acd7fb 100755 --- a/apps/catalogue/models/book.py +++ b/apps/catalogue/models/book.py @@ -418,15 +418,18 @@ class Book(models.Model): self.assert_publishable() changes = self.get_current_changes() data = {"lesson_xml": self.wl1_xml(changes=changes)} - if host: - gallery_url = u'%s%s%s%s/' % (host, settings.MEDIA_URL, settings.IMAGE_DIR, self.gallery) - gallery_dir = os.path.join(settings.MEDIA_ROOT, settings.IMAGE_DIR, self.gallery) - if os.path.isdir(gallery_dir): - data['gallery_url'] = gallery_url - attachments = os.listdir(gallery_dir) - else: - attachments = [] - data['attachments'] = json.dumps(attachments) + + if not host: + host = 'https://' + Site.objects.get_current().domain + gallery_url = u'%s%s%s%s/' % (host, settings.MEDIA_URL, settings.IMAGE_DIR, self.gallery) + gallery_dir = os.path.join(settings.MEDIA_ROOT, settings.IMAGE_DIR, self.gallery) + if os.path.isdir(gallery_dir): + data['gallery_url'] = gallery_url + 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)