mirror of https://github.com/jumpserver/jumpserver
添加授权页面
parent
234f378e3f
commit
53c3767b1b
|
@ -1,10 +1,29 @@
|
||||||
# coding: utf-8
|
# coding: utf-8
|
||||||
|
|
||||||
from django.shortcuts import render_to_response
|
from django.shortcuts import render_to_response
|
||||||
|
from django.http import HttpResponseRedirect
|
||||||
from juser.models import User
|
from juser.models import User
|
||||||
|
from jasset.models import Asset
|
||||||
|
|
||||||
|
|
||||||
def perm_user_list(request):
|
def perm_user_list(request):
|
||||||
header_title, path1, path2 = u'查看授权用户 | Perm User Detail.', u'授权管理', u'用户详情'
|
header_title, path1, path2 = u'查看授权用户 | Perm User Detail.', u'授权管理', u'用户详情'
|
||||||
users = User.objects.all()
|
users = User.objects.all()
|
||||||
return render_to_response('jperm/perm_user_list.html', locals(),)
|
return render_to_response('jperm/perm_user_list.html', locals(),)
|
||||||
|
|
||||||
|
|
||||||
|
def perm_add(request):
|
||||||
|
header_title, path1, path2 = u'添加授权 | Add User perm.', u'授权管理', u'添加授权'
|
||||||
|
username = request.GET.get('username', None)
|
||||||
|
if not username:
|
||||||
|
return HttpResponseRedirect('/')
|
||||||
|
|
||||||
|
user = User.objects.get(username=username)
|
||||||
|
permed_hosts = []
|
||||||
|
for perm in user.permission_set.all():
|
||||||
|
permed_hosts.append(perm.asset)
|
||||||
|
|
||||||
|
hosts_all = Asset.objects.all()
|
||||||
|
hosts = list(set(hosts_all) - set(permed_hosts))
|
||||||
|
|
||||||
|
return render_to_response('jperm/perm_add.html', locals())
|
|
@ -8,7 +8,7 @@
|
||||||
<div class="col-lg-10">
|
<div class="col-lg-10">
|
||||||
<div class="ibox float-e-margins">
|
<div class="ibox float-e-margins">
|
||||||
<div class="ibox-title">
|
<div class="ibox-title">
|
||||||
<h5>添加授权 <small> Add perm info.</small></h5>
|
<h5>添加授权 {{ user.name }} <small> Add perm info.</small></h5>
|
||||||
<div class="ibox-tools">
|
<div class="ibox-tools">
|
||||||
<a class="collapse-link">
|
<a class="collapse-link">
|
||||||
<i class="fa fa-chevron-up"></i>
|
<i class="fa fa-chevron-up"></i>
|
||||||
|
@ -36,104 +36,18 @@
|
||||||
<div class="alert alert-success text-center">{{ msg }}</div>
|
<div class="alert alert-success text-center">{{ msg }}</div>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label for="username" class="col-sm-2 control-label">用户名<span class="red-fonts">*</span></label>
|
|
||||||
<div class="col-sm-8">
|
<div class="col-sm-8">
|
||||||
<input id="username" name="username" placeholder="Username" type="text" class="form-control" value={{ username }}>
|
<select id="host_ips" name="host_ips" multiple>
|
||||||
</div>
|
{% for host in hosts %}
|
||||||
</div>
|
<option value="{{ host.id }}">{{ host.ip }}</option>
|
||||||
<div class="hr-line-dashed"></div>
|
|
||||||
<div class="form-group">
|
|
||||||
<label for="password" class="col-sm-2 control-label">密码<span class="red-fonts">*</span></label>
|
|
||||||
<div class="col-sm-8">
|
|
||||||
<input id="password" name="password" placeholder="Password" type="password" class="form-control" value={{ password }}>
|
|
||||||
<span class="help-block m-b-none">
|
|
||||||
登陆web的密码
|
|
||||||
</span>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="hr-line-dashed"></div>
|
|
||||||
<div class="form-group">
|
|
||||||
<label for="ssh_key_pwd1" class="col-sm-2 control-label">密钥密码<span class="red-fonts">*</span></label>
|
|
||||||
<div class="col-sm-8">
|
|
||||||
<input id="ssh_key_pwd1" name="ssh_key_pwd1" placeholder="SSH Key Password" type="password" class="form-control" value="{{ ssh_key_pwd1 }}">
|
|
||||||
<span class="help-block m-b-none">
|
|
||||||
登陆 Jumpserver 使用的SSH密钥的密码
|
|
||||||
</span>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="hr-line-dashed"></div>
|
|
||||||
<div class="form-group">
|
|
||||||
<label for="name" class="col-sm-2 control-label">姓名<span class="red-fonts">*</span></label>
|
|
||||||
<div class="col-sm-8">
|
|
||||||
<input id="name" name="name" placeholder="Name" type="text" class="form-control" value={{ name }} >
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="hr-line-dashed"></div>
|
|
||||||
<div class="form-group">
|
|
||||||
<label for="groups" class="col-lg-2 control-label">属组<span class="red-fonts">*</span></label>
|
|
||||||
<div class="col-sm-8">
|
|
||||||
<select id="groups" name="groups" class="form-control m-b" multiple>
|
|
||||||
{% for group in all_group %}
|
|
||||||
{% if groups_str %}
|
|
||||||
{% if group.id|int2str in groups_str %}
|
|
||||||
<option value="{{ group.id }}" selected>{{ group.name }}</option>
|
|
||||||
{% else %}
|
|
||||||
<option value="{{ group.id }}">{{ group.name }}</option>
|
|
||||||
{% endif %}
|
|
||||||
{% else %}
|
|
||||||
{% if forloop.first %}
|
|
||||||
<option value="{{ group.id }}" selected>{{ group.name }}</option>
|
|
||||||
{% else %}
|
|
||||||
<option value="{{ group.id }}">{{ group.name }}</option>
|
|
||||||
{% endif %}
|
|
||||||
{% endif %}
|
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</select>
|
</select>
|
||||||
|
{% for host in hosts %}
|
||||||
|
|
||||||
|
{% endfor %}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="hr-line-dashed"></div>
|
|
||||||
<div class="form-group">
|
|
||||||
<label for="role" class="col-lg-2 control-label">角色<span class="red-fonts">*</span></label>
|
|
||||||
<div class="col-sm-8">
|
|
||||||
<select id="role" name="role" class="form-control m-b">
|
|
||||||
{% for r, role_name in user_role.items %}
|
|
||||||
{% ifequal r role_post %}
|
|
||||||
<option value="{{ r }}" selected>{{ role_name }}</option>
|
|
||||||
{% else %}
|
|
||||||
<option value="{{ r }}">{{ role_name }}</option>
|
|
||||||
{% endifequal %}
|
|
||||||
{% endfor %}
|
|
||||||
</select>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="hr-line-dashed"></div>
|
|
||||||
<div class="form-group">
|
|
||||||
<label for="ssh_pwd" class="col-sm-2 control-label">SSH密码</label>
|
|
||||||
<div class="col-sm-8">
|
|
||||||
<input id="ssh_pwd" name="ssh_pwd" type="password" placeholder="SSH Password" class="form-control" value="{{ ssh_pwd }}">
|
|
||||||
<span class="help-block m-b-none">
|
|
||||||
如果使用password方式,该密码是用户在后端服务器的密码
|
|
||||||
</span>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="hr-line-dashed"></div>
|
|
||||||
<div class="form-group">
|
|
||||||
<label for="email" class="col-sm-2 control-label">Email</label>
|
|
||||||
<div class="col-sm-8">
|
|
||||||
<input id="email" name="email" type="email" placeholder="Email" class="form-control" value="{{ email }}">
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="hr-line-dashed"></div>
|
|
||||||
<div class="form-group"><label class="col-sm-2 control-label">是否启用</label>
|
|
||||||
<div class="col-sm-8">
|
|
||||||
<div class="radio i-checks">
|
|
||||||
<label><input type="radio" value="1" name="is_active" checked>启用 </label>
|
|
||||||
</div>
|
|
||||||
<div class="radio i-checks">
|
|
||||||
<label><input type="radio" value="0" name="is_active">禁用 </label>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="hr-line-dashed"></div>
|
<div class="hr-line-dashed"></div>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<div class="col-sm-4 col-sm-offset-2">
|
<div class="col-sm-4 col-sm-offset-2">
|
||||||
|
|
|
@ -41,7 +41,7 @@
|
||||||
<tr>
|
<tr>
|
||||||
<td>{{ user.id }}</td>
|
<td>{{ user.id }}</td>
|
||||||
<td>{{ user.username }}</td>
|
<td>{{ user.username }}</td>
|
||||||
<td><a href="add_perm/?username={{ user.user.name }}">添加授权</a></td>
|
<td><a href="../add_perm/?username={{ user.user.name }}">添加授权</a></td>
|
||||||
</tr>
|
</tr>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</tbody>
|
</tbody>
|
||||||
|
|
Loading…
Reference in New Issue