X-Git-Url: https://git.mdrn.pl/redakcja.git/blobdiff_plain/817ce226770c3b003d85b7e77e96360c433c80ed..5649823d030f580e26857963075af04f932c18ba:/src/depot/publishers/woblink.py?ds=inline diff --git a/src/depot/publishers/woblink.py b/src/depot/publishers/woblink.py index 82a43753..e98ec585 100644 --- a/src/depot/publishers/woblink.py +++ b/src/depot/publishers/woblink.py @@ -220,6 +220,12 @@ class Woblink(BasePublisher): 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()) @@ -488,6 +494,7 @@ class Woblink(BasePublisher): '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) @@ -501,12 +508,13 @@ class Woblink(BasePublisher): '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 = {} + d = {'save': ''} 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): + form_name = f'Upload{field_name}' + id_field = f'pub{field_name}ResId' + field_name = field_name.lower() + data = { 'pubId': woblink_id, } @@ -530,10 +542,6 @@ class Woblink(BasePublisher): 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), @@ -580,8 +588,7 @@ class Woblink(BasePublisher): woblink_id, doc.meta.url.slug + '.epub', content, - 'UploadEpub', - 'epub', + '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, - 'UploadMobi', - 'mobi', + 'Mobi', '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, - 'UploadCover', - 'cover', + 'Cover', cover.mime_type() ) return file_id