fix: Node ordering [`parent_key`, `value`]; 修复默认组织Default节点显示问题(存在key为0的Default节点)

pull/5163/head
Bai 2020-12-03 10:41:52 +08:00 committed by 老广
parent af40e46a75
commit 89ec6ba6ef
1 changed files with 3 additions and 2 deletions

View File

@ -354,7 +354,8 @@ class SomeNodesMixin:
def org_root(cls): def org_root(cls):
root = cls.objects.filter(parent_key='')\ root = cls.objects.filter(parent_key='')\
.filter(key__regex=r'^[0-9]+$')\ .filter(key__regex=r'^[0-9]+$')\
.exclude(key__startswith='-') .exclude(key__startswith='-')\
.order_by('key')
if root: if root:
return root[0] return root[0]
else: else:
@ -411,7 +412,7 @@ class Node(OrgModelMixin, SomeNodesMixin, FamilyMixin, NodeAssetsMixin):
class Meta: class Meta:
verbose_name = _("Node") verbose_name = _("Node")
ordering = ['value'] ordering = ['parent_key', 'value']
def __str__(self): def __str__(self):
return self.full_value return self.full_value