Reimplement the IndexInstanceNodeView CBV view as a multi-inheritance CBV with manual super class resolution.
This commit is contained in:
@@ -299,7 +299,7 @@ class IndexListView(SingleObjectListView):
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
class IndexInstanceNodeView(DocumentListView):
|
class IndexInstanceNodeView(DocumentListView, SingleObjectListView):
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def get_item_count(instance, user):
|
def get_item_count(instance, user):
|
||||||
if instance.index_template_node.link_documents:
|
if instance.index_template_node.link_documents:
|
||||||
@@ -322,12 +322,16 @@ class IndexInstanceNodeView(DocumentListView):
|
|||||||
except PermissionDenied:
|
except PermissionDenied:
|
||||||
AccessControlList.objects.check_access(permission_document_indexing_view, request.user, self.index_instance.index)
|
AccessControlList.objects.check_access(permission_document_indexing_view, request.user, self.index_instance.index)
|
||||||
|
|
||||||
return super(IndexInstanceNodeView, self).dispatch(request, *args, **kwargs)
|
|
||||||
|
|
||||||
def get_document_queryset(self):
|
|
||||||
if self.index_instance:
|
if self.index_instance:
|
||||||
if self.index_instance.index_template_node.link_documents:
|
if self.index_instance.index_template_node.link_documents:
|
||||||
return self.index_instance.documents.all()
|
return DocumentListView.dispatch(self, request, *args, **kwargs)
|
||||||
|
|
||||||
|
return SingleObjectListView.dispatch(self, request, *args, **kwargs)
|
||||||
|
|
||||||
|
def get_queryset(self):
|
||||||
|
if self.index_instance:
|
||||||
|
if self.index_instance.index_template_node.link_documents:
|
||||||
|
return DocumentListView.get_queryset(self)
|
||||||
else:
|
else:
|
||||||
self.object_permission = None
|
self.object_permission = None
|
||||||
return self.index_instance.get_children().order_by('value')
|
return self.index_instance.get_children().order_by('value')
|
||||||
@@ -335,6 +339,11 @@ class IndexInstanceNodeView(DocumentListView):
|
|||||||
self.object_permission = None
|
self.object_permission = None
|
||||||
return IndexInstanceNode.objects.none()
|
return IndexInstanceNode.objects.none()
|
||||||
|
|
||||||
|
def get_document_queryset(self):
|
||||||
|
if self.index_instance:
|
||||||
|
if self.index_instance.index_template_node.link_documents:
|
||||||
|
return self.index_instance.documents.all()
|
||||||
|
|
||||||
def get_extra_context(self):
|
def get_extra_context(self):
|
||||||
context = {
|
context = {
|
||||||
'hide_links': True,
|
'hide_links': True,
|
||||||
|
|||||||
Reference in New Issue
Block a user