Fix.
[redakcja.git] / src / depot / publishers / woblink.py
index f77d618..3e1c78c 100644 (file)
@@ -187,6 +187,7 @@ class Woblink(BasePublisher):
                 (self.ROLE_TRANSLATOR, meta.translators, False)
         ]:
             for person_literal in items:
                 (self.ROLE_TRANSLATOR, meta.translators, False)
         ]:
             for person_literal in items:
+                if person_literal is None: continue
                 if person_literal.lang != 'pl':
                     if errors is not None:
                         if obligatory:
                 if person_literal.lang != 'pl':
                     if errors is not None:
                         if obligatory:
@@ -313,12 +314,16 @@ class Woblink(BasePublisher):
         return price
 
     def can_publish(self, site, book):
         return price
 
     def can_publish(self, site, book):
-        wldoc = book.wldocument(librarian2=True)
         d = {
             'warnings': [],
             'errors': [],
             'info': [],
         }
         d = {
             'warnings': [],
             'errors': [],
             'info': [],
         }
+        try:
+            wldoc = book.wldocument(librarian2=True)
+        except:
+            d['errors'].append('Nieprawidłowy dokument.')
+            return d
         errors = []
         book_data = self.get_book_data(site, wldoc, errors)
         for error in errors:
         errors = []
         book_data = self.get_book_data(site, wldoc, errors)
         for error in errors:
@@ -328,6 +333,12 @@ class Woblink(BasePublisher):
                 errlist = d['warnings']
             errlist.append(error.as_html())
 
                 errlist = d['warnings']
             errlist.append(error.as_html())
 
+        if book_data.get('isbn'):
+            d['info'].append(format_html(
+                'ISBN: {isbn}',
+                isbn=book_data['isbn'],
+            ))
+
         if book_data.get('genres'):
             d['info'].append(format_html(
                 'W kategoriach: {cat} ({price} zł)',
         if book_data.get('genres'):
             d['info'].append(format_html(
                 'W kategoriach: {cat} ({price} zł)',
@@ -565,6 +576,12 @@ class Woblink(BasePublisher):
             ).json()['jobId']
             try:
                 file_id = self.wait_for_job(job_id)
             ).json()['jobId']
             try:
                 file_id = self.wait_for_job(job_id)
+                if check:
+                    self.wait_for_job(
+                        self.session.get(
+                            self.CHECK_DEMO_URL % (file_format, woblink_id)
+                        ).json()['jobId']
+                    )
             except AssertionError:
                 if percent < 50:
                     percent += 10
             except AssertionError:
                 if percent < 50:
                     percent += 10
@@ -573,12 +590,6 @@ class Woblink(BasePublisher):
             else:
                 break
 
             else:
                 break
 
-        if check:
-            self.wait_for_job(
-                self.session.get(
-                    self.CHECK_DEMO_URL % (file_format, woblink_id)
-                ).json()['jobId']
-            )
         return file_id
 
     def send_epub(self, woblink_id, doc, gallery_path, fundraising=None):
         return file_id
 
     def send_epub(self, woblink_id, doc, gallery_path, fundraising=None):