X-Git-Url: https://git.mdrn.pl/redakcja.git/blobdiff_plain/042546599575e59a9cb74c91194e3e3af4824447..b15e203d42d3fd0880ca21d6251dca6fa46405c9:/src/depot/publishers/woblink.py
diff --git a/src/depot/publishers/woblink.py b/src/depot/publishers/woblink.py
index c8037fa4..d7d55ea7 100644
--- a/src/depot/publishers/woblink.py
+++ b/src/depot/publishers/woblink.py
@@ -124,6 +124,8 @@ class Woblink(BasePublisher):
STEP1_URL = BASE_URL + 'catalog/edit/%s'
STEP2_URL = BASE_URL + 'catalog/edit/%s/2'
STEP3_URL = BASE_URL + 'catalog/edit/%s/3'
+ STEP4_URL = BASE_URL + 'catalog/edit/%s/4'
+ STEP5_URL = BASE_URL + 'catalog/edit/%s/5'
UPLOAD_URL = BASE_URL + 'file/upload-%s'
JOB_STATUS_URL = BASE_URL + 'task/status'
GENERATE_DEMO_URL = BASE_URL + 'task/run/generate-%s-demo/%s/%d'
@@ -271,7 +273,7 @@ class Woblink(BasePublisher):
parts[1] = m.group(0) + parts[1]
opened = []
- for tag in re.findall(r'<[^>]+[^/>]>', parts[0]):
+ for tag in re.findall(r'<[^>]*[^/>]>', parts[0]):
if tag[1] == '/':
opened.pop()
else:
@@ -288,7 +290,12 @@ class Woblink(BasePublisher):
return lang_code_3to2(meta.language)
def get_price(self, shop, wldoc, errors=None):
- stats = wldoc.get_statistics()['total']
+ try:
+ stats = wldoc.get_statistics()['total']
+ except:
+ if errors:
+ errors.append(NoPrice(shop))
+ return 0
words = stats['words_with_fn']
pages = stats['chars_with_fn'] / 1800
price = shop.get_price(words, pages)
@@ -304,6 +311,7 @@ class Woblink(BasePublisher):
d = {
'warnings': [],
'errors': [],
+ 'info': [],
}
errors = []
book_data = self.get_book_data(shop, wldoc, errors)
@@ -315,11 +323,15 @@ class Woblink(BasePublisher):
errlist.append(error.as_html())
if book_data.get('genres'):
- d['comment'] = format_html(
+ d['info'].append(format_html(
'W kategoriach: {cat} ({price} zÅ)',
cat=', '.join(self.describe_category(g) for g in book_data['genres']),
- price=book_data['price']
- )
+ price=book_data['price'],
+ ))
+ d['info'].append(mark_safe(
+ '' + book_data['abstract']['header'] +
+ '
' + book_data['abstract']['rest']
+ ))
return d
@@ -373,6 +385,8 @@ class Woblink(BasePublisher):
book.woblink_id, wldoc, book.gallery_path(),
fundraising=texts
)
+ self.edit_step4(book.woblink_id, book_data)
+ self.edit_step5(book.woblink_id, book_data)
def get_book_data(self, shop, wldoc, errors=None):
return {
@@ -474,6 +488,16 @@ class Woblink(BasePublisher):
d = self.with_form_name(d, 'EditPublicationStep3')
return self.session.post(self.STEP3_URL % woblink_id, data=d)
+ def edit_step4(self, woblink_id, book_data):
+ d = {}
+ 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 = self.with_form_name(d, 'EditPublicationStep5')
+ return self.session.post(self.STEP5_URL % woblink_id, data=d)
+
def wait_for_job(self, job_id):
while True:
response = self.session.post(