获得role tag

pull/6/head
ibuler 10 years ago
parent 46720dcf0f
commit b01964618d

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

@ -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