More filters in catalogue.
[redakcja.git] / src / depot / legimi.py
index b0015c9..86ad6e5 100644 (file)
@@ -168,20 +168,21 @@ class Legimi:
             "url": model['Url'],
         }
 
             "url": model['Url'],
         }
 
-#    name=files[]
-#    filename
-#    content-type
-#    response: json
-#     success: true
-#     model.Url
-
-    def send_book(self, book):
-        wlbook = book.wldocument(librarian2=True)
+    def send_book(self, book, changes=None):
+        wlbook = book.wldocument(librarian2=True, changes=changes)
         meta = wlbook.meta
 
         cover = LabelMarquiseCover(meta, width=1200).output_file()
         meta = wlbook.meta
 
         cover = LabelMarquiseCover(meta, width=1200).output_file()
-        epub_file = EpubBuilder(cover=MarquiseCover, fundraising=fundraising).build(wlbook).get_file()
-        mobi_file = MobiBuilder(cover=MarquiseCover, fundraising=fundraising).build(wlbook).get_file()
+        epub_file = EpubBuilder(
+            cover=MarquiseCover,
+            fundraising=fundraising,
+            base_url='file://' + book.gallery_path() + '/'
+        ).build(wlbook).get_file()
+        mobi_file = MobiBuilder(
+            cover=MarquiseCover,
+            fundraising=fundraising,
+            base_url='file://' + book.gallery_path() + '/'
+        ).build(wlbook).get_file()
 
         book_data = {
             "Title": meta.title,
 
         book_data = {
             "Title": meta.title,
@@ -196,7 +197,7 @@ class Legimi:
         }
         if meta.isbn_html:
             isbn = meta.isbn_html
         }
         if meta.isbn_html:
             isbn = meta.isbn_html
-            if isbn.upper().startswith('ISBN '):
+            if isbn.upper().startswith(('ISBN ', 'ISBN-')):
                 isbn = isbn[5:]
             isbn = isbn.strip()
             book_data['Isbn'] = isbn
                 isbn = isbn[5:]
             isbn = isbn.strip()
             book_data['Isbn'] = isbn
@@ -314,7 +315,7 @@ class Legimi:
             'SamplesGenerationPercent': '10',
 
             'EnterToTheMarketType': 'No',
             'SamplesGenerationPercent': '10',
 
             'EnterToTheMarketType': 'No',
-            'EnterToTheMarketDate': date.today().strftime('%d.%m.%Y'),
+            'EnterToTheMarketDate': '',
             'HidingDate': '',
             'SalesNoLimitOption': 'false',
             'SalesNoLimitKindle': 'false',
             'HidingDate': '',
             'SalesNoLimitOption': 'false',
             'SalesNoLimitKindle': 'false',
@@ -408,7 +409,7 @@ class Legimi:
             'OriginalEnterToTheMarketType': "No",
             'OriginalHidingDate': "",
             'OriginalEnterToTheMarketDate': "",
             'OriginalEnterToTheMarketType': "No",
             'OriginalHidingDate': "",
             'OriginalEnterToTheMarketDate': "",
-            'EnterToTheMarketType': "No",
+            'EnterToTheMarketType': "Yes",
             'EnterToTheMarketDate': "",
             'HidingDate': "",
             'SalesNoLimitOption': abo,
             'EnterToTheMarketDate': "",
             'HidingDate': "",
             'SalesNoLimitOption': abo,
@@ -424,7 +425,7 @@ class Legimi:
             self.EDIT_SALE_URL % book.legimi_id,
             data=data
         )
             self.EDIT_SALE_URL % book.legimi_id,
             data=data
         )
-        
+
 
 legimi = Legimi(
     settings.LEGIMI_USERNAME,
 
 legimi = Legimi(
     settings.LEGIMI_USERNAME,