Browse Source

获得role tag

pull/6/head
ibuler 10 years ago
parent
commit
b01964618d
  1. 9
      jumpserver/templatetags/mytags.py
  2. 2
      templates/juser/user_list.html

9
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):

2
templates/juser/user_list.html

@ -58,7 +58,7 @@
<td>{{ user.username }}</td>
<td>{{ user.name }}</td>
<td>{{ user.username|groups_str }}</td>
<td>{{ user_roler|get_value:user.role }}</td>
<td>{{ user.id|get_role }}</td>
<td>{{ user.email }}</td>
<td>{{ user.is_active }}</td>
</tr>

Loading…
Cancel
Save