diff --git a/HISTORY.rst b/HISTORY.rst index 345a47490d..76f03726e9 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -12,6 +12,7 @@ * Add database conversion test to the common app. * Fix label display for resolved smart links when not using a dynamic label. * Only show smart link resolution errors to the user with the smart link edit permission. +* Intercept document list view exception and display them as an error message. 3.1.1 (2018-09-18) ================== diff --git a/mayan/apps/documents/views/document_views.py b/mayan/apps/documents/views/document_views.py index ee6477b7e2..270f181edf 100644 --- a/mayan/apps/documents/views/document_views.py +++ b/mayan/apps/documents/views/document_views.py @@ -62,6 +62,20 @@ class DocumentListView(SingleObjectListView): object_permission = permission_document_view queryset_slice = None + def get_context_data(self, **kwargs): + try: + return super(DocumentListView, self).get_context_data(**kwargs) + except Exception as exception: + messages.error( + self.request, _( + 'Error retrieving document list: %(exception)s.' + ) % { + 'exception': exception + } + ) + self.object_list = Document.objects.none() + return super(DocumentListView, self).get_context_data(**kwargs) + def get_document_queryset(self): return Document.objects.defer( 'description', 'uuid', 'date_added', 'language', 'in_trash',