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:
@@ -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)
|
||||
==================
|
||||
|
||||
@@ -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',
|
||||
|
||||
Reference in New Issue
Block a user