mirror of https://github.com/jumpserver/jumpserver
添加默认值
parent
97dcb4ca91
commit
8c9e763f74
|
@ -12,5 +12,3 @@ def skin_config(request):
|
||||||
return render_to_response('skin_config.html')
|
return render_to_response('skin_config.html')
|
||||||
|
|
||||||
|
|
||||||
def header_path(header_title, path1, path2):
|
|
||||||
return header_title, path1, path2
|
|
||||||
|
|
|
@ -10,7 +10,6 @@ from django.shortcuts import render_to_response
|
||||||
|
|
||||||
from juser.models import UserGroup, User
|
from juser.models import UserGroup, User
|
||||||
from connect import PyCrypt, KEY
|
from connect import PyCrypt, KEY
|
||||||
from jumpserver.views import header_path
|
|
||||||
|
|
||||||
|
|
||||||
cryptor = PyCrypt(KEY)
|
cryptor = PyCrypt(KEY)
|
||||||
|
@ -37,7 +36,7 @@ class AddError(Exception):
|
||||||
def group_add(request):
|
def group_add(request):
|
||||||
error = ''
|
error = ''
|
||||||
msg = ''
|
msg = ''
|
||||||
header_title, path1, path2 = header_path('娣诲姞灞炵粍 | Add Group', 'juser', 'group_add')
|
header_title, path1, path2 = '娣诲姞灞炵粍 | Add Group', 'juser', 'group_add'
|
||||||
|
|
||||||
if request.method == 'POST':
|
if request.method == 'POST':
|
||||||
group_name = request.POST.get('group_name', None)
|
group_name = request.POST.get('group_name', None)
|
||||||
|
@ -69,12 +68,10 @@ def group_add(request):
|
||||||
|
|
||||||
|
|
||||||
def group_list(request):
|
def group_list(request):
|
||||||
|
header_title, path1, path2 = '鏌ョ湅灞炵粍 | Add Group', 'juser', 'group_add'
|
||||||
groups = UserGroup.objects.all()
|
groups = UserGroup.objects.all()
|
||||||
return render_to_response('juser/group_list.html',
|
return render_to_response('juser/group_list.html',
|
||||||
{'header_title': u'鏌ョ湅灞炵粍 | Add Group',
|
locals())
|
||||||
'path1': 'juser', 'path2': 'group_add',
|
|
||||||
'groups': groups})
|
|
||||||
|
|
||||||
|
|
||||||
def user_list(request):
|
def user_list(request):
|
||||||
|
@ -100,7 +97,7 @@ def db_del_user(username):
|
||||||
def user_add(request):
|
def user_add(request):
|
||||||
error = ''
|
error = ''
|
||||||
msg = ''
|
msg = ''
|
||||||
|
header_title, path1, path2 = '娣诲姞鐢ㄦ埛 | Add User', 'juser', 'user_add'
|
||||||
user_role = {'SU': u'瓒呯骇绠$悊鍛', 'GA': u'缁勭鐞嗗憳', 'CU': u'鏅氱敤鎴'}
|
user_role = {'SU': u'瓒呯骇绠$悊鍛', 'GA': u'缁勭鐞嗗憳', 'CU': u'鏅氱敤鎴'}
|
||||||
all_group = UserGroup.objects.all()
|
all_group = UserGroup.objects.all()
|
||||||
if request.method == 'POST':
|
if request.method == 'POST':
|
||||||
|
@ -109,13 +106,13 @@ def user_add(request):
|
||||||
name = request.POST.get('name', None)
|
name = request.POST.get('name', None)
|
||||||
email = request.POST.get('email', '')
|
email = request.POST.get('email', '')
|
||||||
groups = request.POST.getlist('groups', None)
|
groups = request.POST.getlist('groups', None)
|
||||||
role = request.POST.get('role', None)
|
role_post = request.POST.get('role', None)
|
||||||
ssh_pwd = request.POST.get('ssh_pwd', None)
|
ssh_pwd = request.POST.get('ssh_pwd', None)
|
||||||
ssh_key_pwd1 = request.POST.get('ssh_key_pwd1', None)
|
ssh_key_pwd1 = request.POST.get('ssh_key_pwd1', None)
|
||||||
is_active = request.POST.get('is_active', '1')
|
is_active = request.POST.get('is_active', '1')
|
||||||
|
|
||||||
try:
|
try:
|
||||||
if None in [username, password, ssh_key_pwd1, name, groups, role, is_active]:
|
if None in [username, password, ssh_key_pwd1, name, groups, role_post, is_active]:
|
||||||
error = u'甯*鍐呭涓嶈兘涓虹┖'
|
error = u'甯*鍐呭涓嶈兘涓虹┖'
|
||||||
raise AddError
|
raise AddError
|
||||||
user = User.objects.filter(username=username)
|
user = User.objects.filter(username=username)
|
||||||
|
@ -132,10 +129,7 @@ def user_add(request):
|
||||||
is_active=is_active, date_joined=time_now)
|
is_active=is_active, date_joined=time_now)
|
||||||
msg = u'娣诲姞鐢ㄦ埛鎴愬姛'
|
msg = u'娣诲姞鐢ㄦ埛鎴愬姛'
|
||||||
return render_to_response('juser/user_add.html',
|
return render_to_response('juser/user_add.html',
|
||||||
{'header_title': u'娣诲姞鐢ㄦ埛 | Add User',
|
locals())
|
||||||
'path1': 'juser', 'path2': 'user_add',
|
|
||||||
'roles': user_role, 'all_group': all_group,
|
|
||||||
'error': error, 'msg': msg})
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -37,14 +37,14 @@
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label for="username" class="col-sm-2 control-label">鐢ㄦ埛鍚<span class="red-fonts">*</span></label>
|
<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">
|
<input id="username" name="username" placeholder="Username" type="text" class="form-control" value={{ username }}>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="hr-line-dashed"></div>
|
<div class="hr-line-dashed"></div>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label for="password" class="col-sm-2 control-label">瀵嗙爜<span class="red-fonts">*</span></label>
|
<label for="password" class="col-sm-2 control-label">瀵嗙爜<span class="red-fonts">*</span></label>
|
||||||
<div class="col-sm-8">
|
<div class="col-sm-8">
|
||||||
<input id="password" name="password" placeholder="Password" type="password" class="form-control">
|
<input id="password" name="password" placeholder="Password" type="password" class="form-control" value={{ password }}>
|
||||||
<span class="help-block m-b-none">
|
<span class="help-block m-b-none">
|
||||||
鐧婚檰web鐨勫瘑鐮
|
鐧婚檰web鐨勫瘑鐮
|
||||||
</span>
|
</span>
|
||||||
|
@ -54,7 +54,7 @@
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label for="ssh_key_pwd1" class="col-sm-2 control-label">瀵嗛挜瀵嗙爜<span class="red-fonts">*</span></label>
|
<label for="ssh_key_pwd1" class="col-sm-2 control-label">瀵嗛挜瀵嗙爜<span class="red-fonts">*</span></label>
|
||||||
<div class="col-sm-8">
|
<div class="col-sm-8">
|
||||||
<input id="ssh_key_pwd1" name="ssh_key_pwd1" placeholder="SSH Key Password" type="password" class="form-control">
|
<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">
|
<span class="help-block m-b-none">
|
||||||
鐧婚檰 Jumpserver 浣跨敤鐨凷SH瀵嗛挜鐨勫瘑鐮
|
鐧婚檰 Jumpserver 浣跨敤鐨凷SH瀵嗛挜鐨勫瘑鐮
|
||||||
</span>
|
</span>
|
||||||
|
@ -64,7 +64,7 @@
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label for="name" class="col-sm-2 control-label">濮撳悕<span class="red-fonts">*</span></label>
|
<label for="name" class="col-sm-2 control-label">濮撳悕<span class="red-fonts">*</span></label>
|
||||||
<div class="col-sm-8">
|
<div class="col-sm-8">
|
||||||
<input id="name" name="name" placeholder="Name" type="text" class="form-control" >
|
<input id="name" name="name" placeholder="Name" type="text" class="form-control" value={{ name }} >
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="hr-line-dashed"></div>
|
<div class="hr-line-dashed"></div>
|
||||||
|
@ -73,10 +73,14 @@
|
||||||
<div class="col-sm-8">
|
<div class="col-sm-8">
|
||||||
<select id="groups" name="groups" class="form-control m-b" multiple>
|
<select id="groups" name="groups" class="form-control m-b" multiple>
|
||||||
{% for group in all_group %}
|
{% for group in all_group %}
|
||||||
{% if forloop.first %}
|
{% if groups and group.id in groups %}
|
||||||
<option value="{{ group.id }}" selected>{{ group.name }}</option>
|
<option value="{{ group.id }}" selected>{{ group.name }}</option>
|
||||||
{% else %}
|
{% else %}
|
||||||
<option value="{{ group.id }}">{{ group.name }}</option>
|
{% if forloop.first %}
|
||||||
|
<option value="{{ group.id }}" selected>{{ group.name }}</option>
|
||||||
|
{% else %}
|
||||||
|
<option value="{{ group.id }}">{{ group.name }}</option>
|
||||||
|
{% endif %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</select>
|
</select>
|
||||||
|
@ -87,8 +91,12 @@
|
||||||
<label for="role" class="col-lg-2 control-label">瑙掕壊<span class="red-fonts">*</span></label>
|
<label for="role" class="col-lg-2 control-label">瑙掕壊<span class="red-fonts">*</span></label>
|
||||||
<div class="col-sm-8">
|
<div class="col-sm-8">
|
||||||
<select id="role" name="role" class="form-control m-b">
|
<select id="role" name="role" class="form-control m-b">
|
||||||
{% for r, role in roles.items %}
|
{% for r, role_name in user_role %}
|
||||||
<option value="{{ r }}">{{ role }}</option>
|
{% ifequal r role_post %}
|
||||||
|
<option value="{{ r }}" selected>{{ role_name }}</option>
|
||||||
|
{% else %}
|
||||||
|
<option value="{{ r }}">{{ role_name }}</option>
|
||||||
|
{% endifequal %}
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
|
@ -97,7 +105,7 @@
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label for="ssh_pwd" class="col-sm-2 control-label">SSH瀵嗙爜</label>
|
<label for="ssh_pwd" class="col-sm-2 control-label">SSH瀵嗙爜</label>
|
||||||
<div class="col-sm-8">
|
<div class="col-sm-8">
|
||||||
<input id="ssh_pwd" name="ssh_pwd" type="password" placeholder="SSH Password" class="form-control">
|
<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">
|
<span class="help-block m-b-none">
|
||||||
濡傛灉浣跨敤password鏂瑰紡锛璇ュ瘑鐮佹槸鐢ㄦ埛鍦ㄥ悗绔湇鍔″櫒鐨勫瘑鐮
|
濡傛灉浣跨敤password鏂瑰紡锛璇ュ瘑鐮佹槸鐢ㄦ埛鍦ㄥ悗绔湇鍔″櫒鐨勫瘑鐮
|
||||||
</span>
|
</span>
|
||||||
|
@ -107,12 +115,11 @@
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label for="email" class="col-sm-2 control-label">Email</label>
|
<label for="email" class="col-sm-2 control-label">Email</label>
|
||||||
<div class="col-sm-8">
|
<div class="col-sm-8">
|
||||||
<input id="email" name="email" type="email" placeholder="Email" class="form-control">
|
<input id="email" name="email" type="email" placeholder="Email" class="form-control" value="{{ email }}">
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="hr-line-dashed"></div>
|
<div class="hr-line-dashed"></div>
|
||||||
<div class="form-group"><label class="col-sm-2 control-label">鏄惁鍚敤</label>
|
<div class="form-group"><label class="col-sm-2 control-label">鏄惁鍚敤</label>
|
||||||
|
|
||||||
<div class="col-sm-8">
|
<div class="col-sm-8">
|
||||||
<div class="radio i-checks">
|
<div class="radio i-checks">
|
||||||
<label><input type="radio" value="1" name="is_active" checked>鍚敤 </label>
|
<label><input type="radio" value="1" name="is_active" checked>鍚敤 </label>
|
||||||
|
|
Loading鈥
Reference in New Issue