mirror of https://github.com/jumpserver/jumpserver
修改chgSudo的view
parent
50b7d00683
commit
9020c11bd2
|
@ -635,12 +635,13 @@ def chgSudo(request):
|
|||
username = request.POST.get('username')
|
||||
user_dn = 'cn=%s,ou=Sudoers,%s' % (str(username), ldap_base_dn)
|
||||
msg = ''
|
||||
if request.POST.get('addHost') or request.POST.get('delHost'):
|
||||
host = request.POST.get('host')
|
||||
if request.POST.get('add_host') or request.POST.get('del_host'):
|
||||
host = request.POST.get('add_host') if request.POST.get('add_host') else request.POST.get('del_host')
|
||||
hosts = host.split(',')
|
||||
ori_hosts = l.list('entryDN=cn=%s,ou=Sudoers,%s' %
|
||||
(str(username), ldap_base_dn), attr=['sudoHost']).get('sudoHost')
|
||||
if request.POST.get('addHost'):
|
||||
|
||||
if request.POST.get('add_host'):
|
||||
new_hosts = list(set(ori_hosts.extend(hosts)))
|
||||
else:
|
||||
new_hosts = list(set(ori_hosts) - set(hosts))
|
||||
|
@ -648,12 +649,12 @@ def chgSudo(request):
|
|||
|
||||
msg = '修改sudo主机成功' % hosts
|
||||
|
||||
if request.POST.get('addCMD') or request.POST.get('delCMD'):
|
||||
cmd = request.POST.get('cmd')
|
||||
if request.POST.get('add_cmd') or request.POST.get('del_cmd'):
|
||||
cmd = request.POST.get('add_cmd') if request.POST.get('add_cmd') else request.POST.get('del_cmd')
|
||||
cmds = cmd.split(',')
|
||||
ori_cmds = l.list('entryDN=cn=%s,ou=Sudoers,%s' %
|
||||
(str(username), ldap_base_dn), attr=['sudoCommand']).get('sudoCommand')
|
||||
if request.POST.get('addCMD'):
|
||||
if request.POST.get('add_cmd'):
|
||||
new_cmds = list(set(ori_cmds.extend(cmds)))
|
||||
else:
|
||||
new_cmds = list(set(ori_hosts) - cmds)
|
||||
|
|
|
@ -2,12 +2,12 @@
|
|||
{% block content %}
|
||||
<fieldset >
|
||||
<legend>{{ username }}--修改sudo</legend>
|
||||
<form class="form-horizontal" role="form" method="post" action="/chgSudo/?addHost=1" >
|
||||
<form class="form-horizontal" role="form" method="post" action="/chgSudo/" >
|
||||
<div class="row">
|
||||
<div class="col-lg-6">
|
||||
<div class="input-group">
|
||||
<input type="text" name="username" value="{{ username }}" hidden="hidden">
|
||||
<input type="text" class="form-control" name="host" placeholder="主机IP,多个逗号分隔">
|
||||
<input type="text" class="form-control" name="add_host" placeholder="主机IP,多个逗号分隔">
|
||||
<span class="input-group-btn">
|
||||
<button class="btn btn-success" type="submit">新增主机</button>
|
||||
</span>
|
||||
|
@ -17,12 +17,12 @@
|
|||
</form>
|
||||
<br>
|
||||
|
||||
<form class="form-horizontal" role="form" method="post" action="/chgSudo/?delHost=1" >
|
||||
<form class="form-horizontal" role="form" method="post" action="/chgSudo/" >
|
||||
<div class="row">
|
||||
<div class="col-lg-6">
|
||||
<div class="input-group">
|
||||
<input type="text" name="username" value="{{ username }}" hidden="hidden">
|
||||
<input type="text" class="form-control" name="host" placeholder="主机IP,多个逗号分隔">
|
||||
<input type="text" class="form-control" name="del_host" placeholder="主机IP,多个逗号分隔">
|
||||
<span class="input-group-btn">
|
||||
<button class="btn btn-primary" type="submit">删除主机</button>
|
||||
</span>
|
||||
|
@ -32,12 +32,12 @@
|
|||
</form>
|
||||
<br>
|
||||
|
||||
<form class="form-horizontal" role="form" method="post" action="/chgSudo/?addCMD=1" >
|
||||
<form class="form-horizontal" role="form" method="post" action="/chgSudo/" >
|
||||
<div class="row">
|
||||
<div class="col-lg-6">
|
||||
<div class="input-group">
|
||||
<input type="text" name="username" value="{{ username }}" hidden="hidden">
|
||||
<input type="text" class="form-control" name="cmd" placeholder="添加命令,多个逗号分隔">
|
||||
<input type="text" class="form-control" name="add_cmd" placeholder="添加命令,多个逗号分隔">
|
||||
<span class="input-group-btn">
|
||||
<button class="btn btn-info" type="submit">添加命令</button>
|
||||
</span>
|
||||
|
@ -52,7 +52,7 @@
|
|||
<div class="col-lg-6">
|
||||
<div class="input-group">
|
||||
<input type="text" name="username" value="{{ username }}" hidden="hidden">
|
||||
<input type="text" class="form-control" name="cmd" placeholder="删除命令,多个逗号分隔">
|
||||
<input type="text" class="form-control" name="del_cmd" placeholder="删除命令,多个逗号分隔">
|
||||
<span class="input-group-btn">
|
||||
<button class="btn btn-danger" type="submit">删除命令</button>
|
||||
</span>
|
||||
|
|
Loading…
Reference in New Issue