Parcourir la source

Does not tell user when preview exceptions occur

Adrien Panay il y a 7 ans
Parent
révision
a289823095
1 fichiers modifiés avec 7 ajouts et 11 suppressions
  1. 7 11
      tracim/tracim/controllers/content.py

+ 7 - 11
tracim/tracim/controllers/content.py Voir le fichier

@@ -223,10 +223,9 @@ class UserWorkspaceFolderFileRestController(TIMWorkspaceContentRestController):
223 223
         try:
224 224
             nb_page = preview_manager.get_page_nb(file_path=file_path)
225 225
         except PreviewGeneratorException as e:
226
+            # INFO - A.P - Silently intercepts preview exception
227
+            # As preview generation isn't mandatory, just register it
226 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 229
         preview_urls = []
231 230
         for page in range(int(nb_page)):
232 231
             url_str = '/previews/{}/pages/{}?revision_id={}'
@@ -235,18 +234,15 @@ class UserWorkspaceFolderFileRestController(TIMWorkspaceContentRestController):
235 234
                                  revision_id)
236 235
             preview_urls.append(url)
237 236
 
238
-        pdf_available = 'false'  # type: str
237
+        enable_pdf_buttons = False  # type: bool
239 238
         try:
240 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 241
         except PreviewGeneratorException as e:
242
+            # INFO - A.P - Silently intercepts preview exception
243
+            # As preview generation isn't mandatory, just register it
246 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 247
         fake_api_breadcrumb = self.get_breadcrumb(file_id)
252 248
         fake_api_content = DictLikeClass(breadcrumb=fake_api_breadcrumb,