modify cmd_group num bug

pull/12/head
ibuler 2015-07-03 21:27:20 +08:00
parent f7e70e56e3
commit 32ab051bbc
3 changed files with 7 additions and 13 deletions

View File

@ -30,5 +30,5 @@ web_socket_host = 192.168.40.140:3000
email_host = smtp.qq.com email_host = smtp.qq.com
email_port = 25 email_port = 25
email_host_user = 1152704203@qq.com email_host_user = 1152704203@qq.com
email_host_password = xxxxx email_host_password = Hudie117...
email_use_tls = False email_use_tls = False

View File

@ -359,18 +359,12 @@ def sudo_cmd_count(user_group_id):
@register.filter(name='sudo_cmd_count') @register.filter(name='sudo_cmd_count')
def sudo_cmd_count(user_group_id): def sudo_cmd_count(cmd_group_id):
user_group = UserGroup.objects.filter(id=user_group_id) cmd_group = CmdGroup.objects.filter(id=cmd_group_id)
cmds = [] cmds = []
if user_group: if cmd_group:
user_group = user_group[0] cmd_group = cmd_group[0]
cmd_groups = [] return len(set(cmd_group.cmd.split(',')))
for perm in user_group.sudoperm_set.all():
cmd_groups.extend(perm.cmd_group.all())
for cmd_group in cmd_groups:
cmds.extend(cmd_group.cmd.split(','))
return len(set(cmds))
else: else:
return 0 return 0

View File

@ -143,7 +143,7 @@
<i class="fa fa-linux"></i> <i class="fa fa-linux"></i>
<b>{{ cmd_group.name }}</b> <b>{{ cmd_group.name }}</b>
<br> <br>
<small class="text-navy">共: {{ cmd_group.id|sudo_cmd_count }} 个</small> <small class="text-navy">共: {{ cmd_group.id | sudo_cmd_count }} 个</small>
</div> </div>
<div class="col-xs-7 content no-top-border"> <div class="col-xs-7 content no-top-border">
<p class="m-b-xs"><strong>{{ group.comment }}</strong></p> <p class="m-b-xs"><strong>{{ group.comment }}</strong></p>