From b01964618d0a67251f0f091bba5b7110e96213dc Mon Sep 17 00:00:00 2001 From: ibuler Date: Wed, 21 Jan 2015 22:23:05 +0800 Subject: [PATCH] =?UTF-8?q?=E8=8E=B7=E5=BE=97role=20tag?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- jumpserver/templatetags/mytags.py | 9 ++++++--- templates/juser/user_list.html | 2 +- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/jumpserver/templatetags/mytags.py b/jumpserver/templatetags/mytags.py index ff80481bf..0ac92cc85 100644 --- a/jumpserver/templatetags/mytags.py +++ b/jumpserver/templatetags/mytags.py @@ -18,9 +18,12 @@ def int2str(value): return str(value) -@register.filter(name='get_value') -def get_value(dicts, key): - return dicts.get(key, '') +@register.filter(name='get_role') +def get_role(user_id): + user_role = {'SU': u'超级管理员', 'GA': u'组管理员', 'CU': u'普通用户'} + user = User.objects.get(id=user_id) + return user_role.get(user.role) + @register.filter(name='groups_str') def groups_str(username): diff --git a/templates/juser/user_list.html b/templates/juser/user_list.html index 263681214..9c30bb01f 100644 --- a/templates/juser/user_list.html +++ b/templates/juser/user_list.html @@ -58,7 +58,7 @@ {{ user.username }} {{ user.name }} {{ user.username|groups_str }} - {{ user_roler|get_value:user.role }} + {{ user.id|get_role }} {{ user.email }} {{ user.is_active }}