From bab4326aeb11393eee0821ac1311995b1cc044f2 Mon Sep 17 00:00:00 2001 From: ibuler Date: Thu, 4 Jul 2019 16:41:38 +0800 Subject: [PATCH] =?UTF-8?q?[Update]=20=E4=BC=98=E5=8C=96=E8=8A=82=E7=82=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/assets/models/node.py | 2 +- apps/assets/views/admin_user.py | 5 +---- apps/assets/views/system_user.py | 3 ++- 3 files changed, 4 insertions(+), 6 deletions(-) diff --git a/apps/assets/models/node.py b/apps/assets/models/node.py index 6190357df..bdb12fa6f 100644 --- a/apps/assets/models/node.py +++ b/apps/assets/models/node.py @@ -402,7 +402,7 @@ class Node(OrgModelMixin, FamilyMixin, FullValueMixin, AssetsAmountMixin): def get_queryset(cls): from ..utils import NodeUtil util = NodeUtil() - return util.nodes + return sorted(util.nodes) @classmethod def generate_fake(cls, count=100): diff --git a/apps/assets/views/admin_user.py b/apps/assets/views/admin_user.py index d551b81e0..455ca4a9d 100644 --- a/apps/assets/views/admin_user.py +++ b/apps/assets/views/admin_user.py @@ -78,13 +78,10 @@ class AdminUserDetailView(PermissionsMixin, DetailView): permission_classes = [IsOrgAdmin] def get_context_data(self, **kwargs): - from ..utils import NodeUtil - nodes = Node.objects.all() - util = NodeUtil() context = { 'app': _('Assets'), 'action': _('Admin user detail'), - 'nodes': util.get_nodes_by_queryset(queryset=nodes), + 'nodes': Node.get_queryset(), } kwargs.update(context) return super().get_context_data(**kwargs) diff --git a/apps/assets/views/system_user.py b/apps/assets/views/system_user.py index ca363ac03..b47c9eb7d 100644 --- a/apps/assets/views/system_user.py +++ b/apps/assets/views/system_user.py @@ -74,10 +74,11 @@ class SystemUserDetailView(PermissionsMixin, DetailView): permission_classes = [IsOrgAdmin] def get_context_data(self, **kwargs): + cmd_filters_remain = CommandFilter.objects.exclude(system_users=self.object) context = { 'app': _('Assets'), 'action': _('System user detail'), - 'cmd_filters_remain': CommandFilter.objects.exclude(system_users=self.object) + 'cmd_filters_remain': cmd_filters_remain, } kwargs.update(context) return super().get_context_data(**kwargs)