Move code to calculate an index descendant node instances to the model, catch exception when index is still not initialized, possible cause of issue #28
This commit is contained in:
@@ -53,6 +53,12 @@ class Index(models.Model):
|
|||||||
def natural_key(self):
|
def natural_key(self):
|
||||||
return (self.name,)
|
return (self.name,)
|
||||||
|
|
||||||
|
def get_instance_node_count(self):
|
||||||
|
try:
|
||||||
|
return self.instance_root.get_descendant_count()
|
||||||
|
except IndexInstanceNode.DoesNotExist:
|
||||||
|
return 0
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
verbose_name = _(u'index')
|
verbose_name = _(u'index')
|
||||||
verbose_name_plural = _(u'indexes')
|
verbose_name_plural = _(u'indexes')
|
||||||
|
|||||||
@@ -310,7 +310,7 @@ def index_list(request):
|
|||||||
'title': _(u'indexes'),
|
'title': _(u'indexes'),
|
||||||
'hide_links': True,
|
'hide_links': True,
|
||||||
'extra_columns': [
|
'extra_columns': [
|
||||||
{'name': _(u'nodes'), 'attribute': encapsulate(lambda x: x.instance_root.get_descendant_count())},
|
{'name': _(u'nodes'), 'attribute': 'get_instance_node_count'},
|
||||||
{'name': _(u'document types'), 'attribute': 'get_document_types_names'},
|
{'name': _(u'document types'), 'attribute': 'get_document_types_names'},
|
||||||
],
|
],
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user