Use audience->thema in legimi too.
[redakcja.git] / src / depot / publishers / woblink.py
index 82a4375..e98ec58 100644 (file)
@@ -220,6 +220,12 @@ class Woblink(BasePublisher):
             if errors is not None:
                 errors.append(NoMainThemaWarning())
         thema_codes.extend(meta.thema)
             if errors is not None:
                 errors.append(NoMainThemaWarning())
         thema_codes.extend(meta.thema)
+
+        thema_codes.extend(
+            Audience.objects.filter(code__in=meta.audiences).exclude(
+                thema=None).values_list('thema', flat=True)
+        )
+
         if not thema_codes:
             if errors is not None:
                 errors.append(NoThema())
         if not thema_codes:
             if errors is not None:
                 errors.append(NoThema())
@@ -488,6 +494,7 @@ class Woblink(BasePublisher):
             'pubFileFormat': 'epub+mobi',
             'pubIsAcs': '0',
             'pubPublisherIndex': '',
             'pubFileFormat': 'epub+mobi',
             'pubIsAcs': '0',
             'pubPublisherIndex': '',
+            'save_and_continue': '',
         }
         d = self.with_form_name(d, 'EditPublicationStep3')
         return self.session.post(self.STEP3_URL % woblink_id, data=d)
         }
         d = self.with_form_name(d, 'EditPublicationStep3')
         return self.session.post(self.STEP3_URL % woblink_id, data=d)
@@ -501,12 +508,13 @@ class Woblink(BasePublisher):
             'pubMobiDemoResId': mobi_demo,
             'pubFileFormat': 'epub+mobi',
             'pubId': woblink_id,
             'pubMobiDemoResId': mobi_demo,
             'pubFileFormat': 'epub+mobi',
             'pubId': woblink_id,
+            'save_and_continue': '',
         }
         d = self.with_form_name(d, 'EditPublicationStep4')
         return self.session.post(self.STEP4_URL % woblink_id, data=d)
 
     def edit_step5(self, woblink_id, book_data):
         }
         d = self.with_form_name(d, 'EditPublicationStep4')
         return self.session.post(self.STEP4_URL % woblink_id, data=d)
 
     def edit_step5(self, woblink_id, book_data):
-        d = {}
+        d = {'save': ''}
         d = self.with_form_name(d, 'EditPublicationStep5')
         return self.session.post(self.STEP5_URL % woblink_id, data=d)
 
         d = self.with_form_name(d, 'EditPublicationStep5')
         return self.session.post(self.STEP5_URL % woblink_id, data=d)
 
@@ -523,6 +531,10 @@ class Woblink(BasePublisher):
             sleep(2)
 
     def upload_file(self, woblink_id, filename, content, field_name, mime_type):
             sleep(2)
 
     def upload_file(self, woblink_id, filename, content, field_name, mime_type):
+        form_name = f'Upload{field_name}'
+        id_field = f'pub{field_name}ResId'
+        field_name = field_name.lower()
+
         data = {
             'pubId': woblink_id,
         }
         data = {
             'pubId': woblink_id,
         }
@@ -530,10 +542,6 @@ class Woblink(BasePublisher):
             field_name: (filename, content, mime_type)
         }
         
             field_name: (filename, content, mime_type)
         }
         
-        form_name = f'Upload{field_name}'
-        id_field = f'pub{field_name}ResId'
-        field_name = field_name.lower()
-
         response = self.session.post(
             self.UPLOAD_URL % field_name,
             data=self.with_form_name(data, form_name),
         response = self.session.post(
             self.UPLOAD_URL % field_name,
             data=self.with_form_name(data, form_name),
@@ -580,8 +588,7 @@ class Woblink(BasePublisher):
             woblink_id,
             doc.meta.url.slug + '.epub',
             content,
             woblink_id,
             doc.meta.url.slug + '.epub',
             content,
-            'UploadEpub',
-            'epub',
+            'Epub',
             'application/epub+zip'
         )
         demo_id = self.generate_demo(woblink_id, 'epub')
             'application/epub+zip'
         )
         demo_id = self.generate_demo(woblink_id, 'epub')
@@ -597,8 +604,7 @@ class Woblink(BasePublisher):
             woblink_id,
             doc.meta.url.slug + '.mobi',
             content,
             woblink_id,
             doc.meta.url.slug + '.mobi',
             content,
-            'UploadMobi',
-            'mobi',
+            'Mobi',
             'application/x-mobipocket-ebook'
         )
         demo_id = self.generate_demo(woblink_id, 'mobi', check=False)
             'application/x-mobipocket-ebook'
         )
         demo_id = self.generate_demo(woblink_id, 'mobi', check=False)
@@ -616,8 +622,7 @@ class Woblink(BasePublisher):
             woblink_id,
             doc.meta.url.slug + '.jpeg',
             content,
             woblink_id,
             doc.meta.url.slug + '.jpeg',
             content,
-            'UploadCover',
-            'cover',
+            'Cover',
             cover.mime_type()
         )
         return file_id
             cover.mime_type()
         )
         return file_id