Use audience->thema in legimi too.
[redakcja.git] / src / depot / publishers / woblink.py
index c373d81..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),