From d1f19a5cad5d204797fd889954966d30edbd230b Mon Sep 17 00:00:00 2001 From: guanghongwei Date: Sat, 14 Mar 2015 13:15:33 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E9=83=A8=E9=97=A8=E6=98=BE?= =?UTF-8?q?=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- jumpserver/templatetags/mytags.py | 19 +++++++++++++++---- templates/jperm/dept_perm_list.html | 4 ++-- templates/juser/dept_list.html | 7 +++++-- 3 files changed, 22 insertions(+), 8 deletions(-) diff --git a/jumpserver/templatetags/mytags.py b/jumpserver/templatetags/mytags.py index b91c91ddb..bd2dc09db 100644 --- a/jumpserver/templatetags/mytags.py +++ b/jumpserver/templatetags/mytags.py @@ -83,8 +83,9 @@ def member_count(group_id): group = UserGroup.objects.get(id=group_id) return group.user_set.count() -@register.filter(name='dept_member') -def dept_member(dept_id): + +@register.filter(name='dept_user_num') +def dept_user_num(dept_id): dept = DEPT.objects.filter(id=dept_id) if dept: dept = dept[0] @@ -93,14 +94,24 @@ def dept_member(dept_id): return 0 +@register.filter(name='dept_group_num') +def dept_group_num(dept_id): + dept = DEPT.objects.filter(id=dept_id) + if dept: + dept = dept[0] + return dept.usergroup_set.all().count() + else: + return 0 + + @register.filter(name='perm_count') def perm_count(group_id): group = UserGroup.objects.get(id=group_id) return group.perm_set.count() -@register.filter(name='dept_perm_count') -def dept_perm_count(dept_id): +@register.filter(name='dept_asset_num') +def dept_asset_num(dept_id): dept = DEPT.objects.filter(id=dept_id) if dept: dept = dept[0] diff --git a/templates/jperm/dept_perm_list.html b/templates/jperm/dept_perm_list.html index eb945cf3a..a4f3b7afa 100644 --- a/templates/jperm/dept_perm_list.html +++ b/templates/jperm/dept_perm_list.html @@ -58,8 +58,8 @@ {% for dept in contacts.object_list %} {{ dept.name }} - {{ dept.id | dept_member }} - {{ dept.id | dept_perm_count }} + {{ dept.id | dept_user_num }} + {{ dept.id | dept_asset_num }} {{ dept.comment }} 主机 diff --git a/templates/juser/dept_list.html b/templates/juser/dept_list.html index e8aa56614..ee5d9b1f3 100644 --- a/templates/juser/dept_list.html +++ b/templates/juser/dept_list.html @@ -51,7 +51,9 @@ 部门名称 + 小组数目 成员数目 + 主机数目 备注 操作 @@ -63,10 +65,11 @@ {{ dept.name }} - {{ dept.id | dept_member }} + {{ dept.id | dept_group_num}} + {{ dept.id | dept_user_num}} + {{ dept.id | dept_asset_num}} {{ dept.comment }} - 成员 编辑 删除