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 %}