|
|
|
|
223
|
try:
|
223
|
try:
|
224
|
nb_page = preview_manager.get_page_nb(file_path=file_path)
|
224
|
nb_page = preview_manager.get_page_nb(file_path=file_path)
|
225
|
except PreviewGeneratorException as e:
|
225
|
except PreviewGeneratorException as e:
|
|
|
226
|
+ # INFO - A.P - Silently intercepts preview exception
|
|
|
227
|
+ # As preview generation isn't mandatory, just register it
|
226
|
logger.debug(self, 'Exception: {}'.format(e.__str__))
|
228
|
logger.debug(self, 'Exception: {}'.format(e.__str__))
|
227
|
- msg_str = _('Sorry... No preview for {}: {}') # type: str
|
|
|
228
|
- msg = msg_str.format(file.file_name, str(e)) # type: str
|
|
|
229
|
- tg.flash(msg, CST.STATUS_ERROR)
|
|
|
230
|
preview_urls = []
|
229
|
preview_urls = []
|
231
|
for page in range(int(nb_page)):
|
230
|
for page in range(int(nb_page)):
|
232
|
url_str = '/previews/{}/pages/{}?revision_id={}'
|
231
|
url_str = '/previews/{}/pages/{}?revision_id={}'
|
|
|
|
|
235
|
revision_id)
|
234
|
revision_id)
|
236
|
preview_urls.append(url)
|
235
|
preview_urls.append(url)
|
237
|
|
236
|
|
238
|
- pdf_available = 'false' # type: str
|
|
|
|
|
237
|
+ enable_pdf_buttons = False # type: bool
|
239
|
try:
|
238
|
try:
|
240
|
enable_pdf_buttons = \
|
239
|
enable_pdf_buttons = \
|
241
|
- preview_manager.has_pdf_preview(
|
|
|
242
|
- file_path=file_path,
|
|
|
243
|
- ) # type: bool
|
|
|
244
|
- pdf_available = str(enable_pdf_buttons).lower()
|
|
|
|
|
240
|
+ preview_manager.has_pdf_preview(file_path=file_path)
|
245
|
except PreviewGeneratorException as e:
|
241
|
except PreviewGeneratorException as e:
|
|
|
242
|
+ # INFO - A.P - Silently intercepts preview exception
|
|
|
243
|
+ # As preview generation isn't mandatory, just register it
|
246
|
logger.debug(self, 'Exception: {}'.format(e.__str__))
|
244
|
logger.debug(self, 'Exception: {}'.format(e.__str__))
|
247
|
- msg_str = _('Sorry... No PDF downloads for {}: {}') # type: str
|
|
|
248
|
- msg = msg_str.format(file.file_name, str(e)) # type: str
|
|
|
249
|
- tg.flash(msg, CST.STATUS_ERROR)
|
|
|
|
|
245
|
+ pdf_available = str(enable_pdf_buttons).lower()
|
250
|
|
246
|
|
251
|
fake_api_breadcrumb = self.get_breadcrumb(file_id)
|
247
|
fake_api_breadcrumb = self.get_breadcrumb(file_id)
|
252
|
fake_api_content = DictLikeClass(breadcrumb=fake_api_breadcrumb,
|
248
|
fake_api_content = DictLikeClass(breadcrumb=fake_api_breadcrumb,
|