Intercept document list view exception and display them as an error message.

Signed-off-by: Roberto Rosario <roberto.rosario.gonzalez@gmail.com>
This commit is contained in:
Roberto Rosario
2018-09-21 02:10:20 -04:00
parent ff5a0d32d4
commit 758a14e358
2 changed files with 15 additions and 0 deletions

View File

@@ -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)
==================

View File

@@ -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',