|
@@ -220,35 +220,47 @@ class UserWorkspaceFolderFileRestController(TIMWorkspaceContentRestController):
|
220
|
220
|
file_path = content_api.get_one_revision_filepath(revision_id)
|
221
|
221
|
|
222
|
222
|
nb_page = 0
|
223
|
|
- try:
|
224
|
|
- nb_page = preview_manager.get_page_nb(file_path=file_path)
|
225
|
|
- except PreviewGeneratorException as e:
|
226
|
|
- # INFO - A.P - Silently intercepts preview exception
|
227
|
|
- # As preview generation isn't mandatory, just register it
|
228
|
|
- logger.debug(self, 'Exception: {}'.format(e.__str__))
|
|
223
|
+ enable_pdf_buttons = False # type: bool
|
229
|
224
|
preview_urls = []
|
230
|
|
- for page in range(int(nb_page)):
|
231
|
|
- url_str = '/previews/{}/pages/{}?revision_id={}'
|
232
|
|
- url = url_str.format(file_id,
|
233
|
|
- page,
|
234
|
|
- revision_id)
|
235
|
|
- preview_urls.append(url)
|
236
|
225
|
|
237
|
|
- enable_pdf_buttons = False # type: bool
|
238
|
226
|
try:
|
|
227
|
+ nb_page = preview_manager.get_page_nb(file_path=file_path)
|
|
228
|
+ for page in range(int(nb_page)):
|
|
229
|
+ url_str = '/previews/{}/pages/{}?revision_id={}'
|
|
230
|
+ url = url_str.format(file_id,
|
|
231
|
+ page,
|
|
232
|
+ revision_id)
|
|
233
|
+ preview_urls.append(url)
|
|
234
|
+
|
239
|
235
|
enable_pdf_buttons = \
|
240
|
236
|
preview_manager.has_pdf_preview(file_path=file_path)
|
|
237
|
+
|
241
|
238
|
except PreviewGeneratorException as e:
|
242
|
239
|
# INFO - A.P - Silently intercepts preview exception
|
243
|
240
|
# As preview generation isn't mandatory, just register it
|
244
|
|
- logger.debug(self, 'Exception: {}'.format(e.__str__))
|
|
241
|
+ logger.debug(
|
|
242
|
+ self,
|
|
243
|
+ 'Preview Generator Exception: {}'.format(e.__str__)
|
|
244
|
+ )
|
|
245
|
+ except Exception as e:
|
|
246
|
+ # INFO - D.A - 2017-08-11 - Make Tracim robust to pg exceptions
|
|
247
|
+ # Preview generator may potentially raise any type of exception
|
|
248
|
+ # so we prevent user interface crashes by catching all exceptions
|
|
249
|
+ logger.error(
|
|
250
|
+ self,
|
|
251
|
+ 'Preview Generator Generic Exception: {}'.format(e.__str__)
|
|
252
|
+ )
|
|
253
|
+
|
245
|
254
|
pdf_available = 'true' if enable_pdf_buttons else 'false' # type: str
|
246
|
255
|
|
247
|
256
|
fake_api_breadcrumb = self.get_breadcrumb(file_id)
|
248
|
|
- fake_api_content = DictLikeClass(breadcrumb=fake_api_breadcrumb,
|
249
|
|
- current_user=current_user_content)
|
250
|
|
- fake_api = Context(CTX.FOLDER,
|
251
|
|
- current_user=user).toDict(fake_api_content)
|
|
257
|
+ fake_api_content = DictLikeClass(
|
|
258
|
+ breadcrumb=fake_api_breadcrumb,
|
|
259
|
+ current_user=current_user_content
|
|
260
|
+ )
|
|
261
|
+ fake_api = Context(CTX.FOLDER, current_user=user)\
|
|
262
|
+ .toDict(fake_api_content)
|
|
263
|
+
|
252
|
264
|
dictified_file = Context(self._get_one_context,
|
253
|
265
|
current_user=user).toDict(file, 'file')
|
254
|
266
|
result = DictLikeClass(result=dictified_file,
|