Update the index information colums to show the

total number of documents and nodes contained in a level.

Signed-off-by: Roberto Rosario <roberto.rosario.gonzalez@gmail.com>
This commit is contained in:
Roberto Rosario
2017-08-02 20:29:59 -04:00
parent cd54f07ee5
commit 68d8ce56c8
3 changed files with 45 additions and 12 deletions

View File

@@ -308,8 +308,21 @@ class IndexInstanceNode(MPTTModel):
# Convenience method for serializer
return self.get_children()
def index(self):
return IndexInstance.objects.get(pk=self.index_template_node.index.pk)
def get_children_count(self):
return self.get_children().count()
def get_descendants_count(self):
return self.get_descendants().count()
def get_descendants_document_count(self, user):
return AccessControlList.objects.filter_by_access(
permission=permission_document_view, user=user,
queryset=Document.objects.filter(
index_instance_nodes__in=self.get_descendants(
include_self=True
)
)
).count()
def get_item_count(self, user):
if self.index_template_node.link_documents:
@@ -356,6 +369,9 @@ class IndexInstanceNode(MPTTModel):
if acquire_lock:
lock.release()
def index(self):
return IndexInstance.objects.get(pk=self.index_template_node.index.pk)
def remove_document(self, document, acquire_lock=True):
"""
The argument `acquire_lock` controls whether or not this method