key目录变化

pull/26/head
ibuler 2015-11-16 22:45:41 +08:00
parent 71ef4b079a
commit 67771105ae
8 changed files with 24 additions and 70 deletions

View File

@ -121,8 +121,7 @@ def db_del_user(username):
def gen_ssh_key(username, password='',
key_dir=os.path.join(BASE_DIR, 'role_keys/user/'),
key_dir=os.path.join(KEY_DIR, 'user'),
authorized_keys=True, home="/home", length=2048):
"""

View File

@ -8,14 +8,11 @@ import uuid as uuid_r
from django.contrib.auth.decorators import login_required
from django.db.models import Q
from django.template import RequestContext
from django.db.models import ObjectDoesNotExist
from jumpserver.settings import EMAIL_HOST_USER
from juser.user_api import *
from jperm.perm_api import _public_perm_api, perm_user_api, user_permed
MAIL_FROM = EMAIL_HOST_USER
def chg_role(request):
role = {'SU': 2, 'GA': 1, 'CU': 0}
if request.session['role_id'] > 0:
@ -142,54 +139,6 @@ def group_edit(request):
return my_render('juser/group_edit.html', locals(), request)
# @require_role(role='admin')
# def group_edit_adm(request):
# error = ''
# msg = ''
# header_title, path1, path2 = '修改小组信息', '用户管理', '编辑小组'
# user, dept = get_session_user_dept(request)
# if request.method == 'GET':
# group_id = request.GET.get('id', '')
# if not validate(request, user_group=[group_id]):
# return HttpResponseRedirect('/juser/group_list/')
# group = UserGroup.objects.filter(id=group_id)
# if group:
# group = group[0]
# users_all = dept.user_set.all()
# users_selected = group.user_set.all()
# users = [user for user in users_all if user not in users_selected]
#
# return render_to_response('juser/group_edit.html', locals(), context_instance=RequestContext(request))
# else:
# group_id = request.POST.get('group_id', '')
# group_name = request.POST.get('group_name', '')
# comment = request.POST.get('comment', '')
# users_selected = request.POST.getlist('users_selected')
#
# users = []
# try:
# if not validate(request, user=users_selected):
# raise ServerError(u'右侧非部门用户')
#
# if not validate(request, user_group=[group_id]):
# raise ServerError(u'没有权限修改本组')
#
# for user_id in users_selected:
# users.extend(User.objects.filter(id=user_id))
#
# user_group = UserGroup.objects.filter(id=group_id)
# if user_group:
# user_group.update(name=group_name, comment=comment, dept=dept)
# user_group = user_group[0]
# user_group.user_set.clear()
# user_group.user_set = users
#
# except ServerError, e:
# error = e
#
# return HttpResponseRedirect('/juser/group_list/')
@login_required(login_url='/login')
@require_role(role='super')
def user_add(request):
@ -210,7 +159,7 @@ def user_add(request):
uuid = uuid_r.uuid1()
ssh_key_pwd = PyCrypt.gen_rand_pass(16)
extra = request.POST.getlist('extra', [])
is_active = True if '0' in extra else False
is_active = False if '0' in extra else True
ssh_key_login_need = True if '1' in extra else False
send_mail_need = True if '2' in extra else False
@ -437,7 +386,6 @@ def user_edit(request):
admin_groups=admin_groups,
role=role_post,
is_active=is_active)
_public_perm_api({'type': 'del_user', 'user': user, 'asset': user_permed(user)})
if email_need:
msg = u"""
@ -528,7 +476,7 @@ def down_key(request):
user = get_object(User, id=user_id)
if user:
username = user.username
private_key_file = os.path.join(BASE_DIR, 'role_keys/jumpserver', username + ".pem")
private_key_file = os.path.join(KEY_DIR, 'user', username)
if os.path.isfile(private_key_file):
f = open(private_key_file)
data = f.read()

View File

@ -17,10 +17,19 @@ function check_all(form) {
}
function checkAll(){
// 选择该页面所有checkbox
$('input[type=checkbox]').each(function(){
$(this).attr('checked', true)
})
var checklist = document.getElementsByName ("checked");
if(document.getElementById("check_all").checked)
{
for(var i=0;i<checklist.length;i++)
{
checklist[i].checked = 1;
}
}else{
for(var j=0;j<checklist.length;j++)
{
checklist[j].checked = 0;
}
}
}
//提取指定行的数据JSON格式

View File

@ -43,7 +43,7 @@
<thead>
<tr>
<th class="text-center">
<input type="checkbox" id="select_all" onclick="selectAll()" name="select_all">
<input type="checkbox" id="check_all" onclick="checkAll()" name="check_all">
</th>
<th class="text-center">组名</th>
<th class="text-center">成员数目</th>
@ -55,7 +55,7 @@
{% for group in user_groups.object_list %}
<tr class="gradeX">
<td class="text-center">
<input type="checkbox" name="selected" value="{{ group.id }}">
<input type="checkbox" name="checked" value="{{ group.id }}">
</td>
<td class="text-center"> {{ group.name }} </td>
<td class="text-center"><a href="/juser/user_list/?gid={{ group.id }}"> {{ group.id | members_count }}</a> </td>

View File

@ -93,10 +93,10 @@
</div>
</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-2">
<div class="checkbox i-checks">
<label><input type="checkbox" value="0" name="extra" ></label>
<label><input type="checkbox" value="0" name="extra" ></label>
</div>
</div>
<div class="col-sm-2">

View File

@ -40,7 +40,7 @@
<div class="form-group">
<label for="password" class="col-sm-2 control-label">密码</label>
<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="{{ user.password }}">
<span class="help-block m-b-none">
登陆web的密码
</span>

View File

@ -42,7 +42,7 @@
<thead>
<tr>
<th class="text-center">
<input type="checkbox" id="select_all" onclick="selectAll()" name="select_all">
<input type="checkbox" id="check_all" onclick="checkAll()">
</th>
<th class="text-center">用户名</th>
<th class="text-center">姓名</th>
@ -57,7 +57,7 @@
{% for user in users.object_list %}
<tr class="gradeX">
<td class="text-center">
<input type="checkbox" name="selected" value="{{ user.id }}">
<input type="checkbox" name="checked" value="{{ user.id }}">
</td>
<td class="text-center"> {{ user.username }} </td>
<td class="text-center"> {{ user.name }} </td>

View File

@ -55,9 +55,7 @@
searchArray.pop();
}
console.log(searchStr);
searchArray.push(old_href);
console.log(searchArray);
if (searchArray.length > 1) {
$(this).attr('href', searchArray.join('&'));
}