From f592e46442db6209333a4b59a50afb68589e769a Mon Sep 17 00:00:00 2001 From: ibuler Date: Wed, 14 Jan 2015 23:51:30 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E7=94=A8=E6=88=B7=E5=88=97?= =?UTF-8?q?=E8=A1=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- jumpserver/templatetags/mytags.py | 12 ++++++++++++ juser/views.py | 1 + templates/juser/user_list.html | 19 ++++++++++++++----- 3 files changed, 27 insertions(+), 5 deletions(-) diff --git a/jumpserver/templatetags/mytags.py b/jumpserver/templatetags/mytags.py index 3ef015a5c..251f81708 100644 --- a/jumpserver/templatetags/mytags.py +++ b/jumpserver/templatetags/mytags.py @@ -15,3 +15,15 @@ def stamp2str(value): @register.filter(name='int2str') def int2str(value): return str(value) + + +@register.filter(name='get_value') +def get_value(dicts, key): + return dicts.get(key, '') + +@register.filter(name='groups_str') +def groups_str(group_list): + groups = [] + for group in group_list: + groups.append(group.name) + return ','.join(groups) \ No newline at end of file diff --git a/juser/views.py b/juser/views.py index ada346a8b..c96fcf5e1 100644 --- a/juser/views.py +++ b/juser/views.py @@ -152,6 +152,7 @@ def group_list(request): def user_list(request): + user_role = {'SU': u'超级管理员', 'GA': u'组管理员', 'CU': u'普通用户'} header_title, path1, path2 = '查看用户 | Add User', 'juser', 'user_list' users = User.objects.all() return render_to_response('juser/user_list.html', locals()) diff --git a/templates/juser/user_list.html b/templates/juser/user_list.html index f4e43683d..bc568fade 100644 --- a/templates/juser/user_list.html +++ b/templates/juser/user_list.html @@ -1,4 +1,5 @@ {% extends 'base.html' %} +{% load mytags %} {% block content %} {% include 'nav_cat_bar.html' %} @@ -39,19 +40,27 @@ ID 用户名 姓名 + 属组 + 角色 + Email + 激活 - {% for group in groups %} + {% for user in users %}
- +
- {{ group.id }} - {{ group.name }} - {{ group.comment }} + {{ user.id }} + {{ user.username }} + {{ user.name }} + {{ user.user_group.all|groups_str }} + {{ user_roler|get_value:user.role }} + {{ user.email }} + {{ user.is_active }} {% endfor %}