remove mismatched html tags
[redakcja.git] / apps / catalogue / models / book.py
index 7589587..d8acd7f 100755 (executable)
@@ -92,10 +92,10 @@ class Book(models.Model):
 
     @classmethod
     @transaction.commit_on_success
-    def create(cls, creator, text, **kwargs):
+    def create(cls, creator, text, commit_args=None, **kwargs):
         b = cls.objects.create(**kwargs)
         b.chunk_set.all().update(creator=creator)
-        b[0].commit(text, author=creator)
+        b[0].commit(text, author=creator, **(commit_args or {}))
         return b
 
     def add(self, *args, **kwargs):
@@ -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.slug)
-            gallery_dir = os.path.join(settings.MEDIA_ROOT, settings.IMAGE_DIR, self.slug)
-            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)