mirror of https://github.com/jumpserver/jumpserver
Merge branch 'dev' of git.coding.net:jumpserver/jumpserver into dev
commit
42745c52df
|
@ -11,17 +11,21 @@ urlpatterns = patterns('juser.views',
|
|||
(r'^group_list/$', group_list),
|
||||
(r'^group_del/$', group_del),
|
||||
(r'^group_edit/$', group_edit),
|
||||
|
||||
(r'^user_add/$', user_add),
|
||||
(r'^user_del/$', 'user_del'),
|
||||
(r'^user_list/$', user_list),
|
||||
(r'^user_edit/$', user_edit),
|
||||
(r'^user_detail/$', 'user_detail'),
|
||||
|
||||
(r'^profile/$', 'profile'),
|
||||
|
||||
(r'^send_mail_retry/$', send_mail_retry),
|
||||
(r'^reset_password/$', reset_password),
|
||||
(r'^forget_password/$', forget_password),
|
||||
(r'^user_detail/$', 'user_detail'),
|
||||
(r'^user_del/$', 'user_del'),
|
||||
(r'^user_edit/$', user_edit),
|
||||
(r'^profile/$', 'profile'),
|
||||
|
||||
(r'^change_info/$', 'change_info'),
|
||||
(r'^regen_ssh_key/$', 'regen_ssh_key'),
|
||||
(r'^change_role/$', 'chg_role'),
|
||||
(r'^regen_ssh_key/$', 'regen_ssh_key'),
|
||||
(r'^down_key/$', 'down_key'),
|
||||
)
|
||||
|
|
|
@ -86,13 +86,14 @@ def db_update_user(**kwargs):
|
|||
groups_post = kwargs.pop('groups')
|
||||
admin_groups_post = kwargs.pop('admin_groups')
|
||||
user_id = kwargs.pop('user_id')
|
||||
user = User.objects.get(id=user_id)
|
||||
user = User.objects.filter(id=user_id)
|
||||
user_get = User.objects.get(id=user_id)
|
||||
if user:
|
||||
pwd = kwargs.pop('password')
|
||||
user.update(**kwargs)
|
||||
if pwd != '':
|
||||
user.set_password(pwd)
|
||||
user.save()
|
||||
user_get.set_password(pwd)
|
||||
user_get.save()
|
||||
else:
|
||||
return None
|
||||
|
||||
|
@ -101,10 +102,10 @@ def db_update_user(**kwargs):
|
|||
for group_id in groups_post:
|
||||
group = UserGroup.objects.filter(id=group_id)
|
||||
group_select.extend(group)
|
||||
user.group = group_select
|
||||
user_get.group = group_select
|
||||
|
||||
if admin_groups_post != '':
|
||||
user.admingroup_set.all().delete()
|
||||
user_get.admingroup_set.all().delete()
|
||||
for group_id in admin_groups_post:
|
||||
group = get_object(UserGroup, id=group_id)
|
||||
AdminGroup(user=user, group=group).save()
|
||||
|
@ -129,9 +130,10 @@ def gen_ssh_key(username, password='',
|
|||
生成一个用户ssh密钥对
|
||||
"""
|
||||
private_key_file = os.path.join(key_dir, username)
|
||||
mkdir(private_key_file, username)
|
||||
if os.path.isfile(private_key_file):
|
||||
os.unlink(private_key_file)
|
||||
ret = bash('ssh-keygen -t rsa -f %s -b %s -P "%s"' % (private_key_file, length, password))
|
||||
ret = bash('echo -e "y\n"|ssh-keygen -t rsa -f %s -b %s -P "%s"' % (private_key_file, length, password))
|
||||
|
||||
if authorized_keys:
|
||||
auth_key_dir = os.path.join(home, username, '.ssh')
|
||||
|
|
|
@ -423,7 +423,7 @@ def profile(request):
|
|||
def change_info(request):
|
||||
header_title, path1, path2 = '修改信息', '用户管理', '修改个人信息'
|
||||
user_id = request.user.id
|
||||
user = get_object(User, id=user_id)
|
||||
user = User.objects.get(id=user_id)
|
||||
error = ''
|
||||
if not user:
|
||||
return HttpResponseRedirect('/')
|
||||
|
@ -433,18 +433,19 @@ def change_info(request):
|
|||
password = request.POST.get('password', '')
|
||||
email = request.POST.get('email', '')
|
||||
|
||||
if '' in [name, password, email]:
|
||||
if '' in [name, email]:
|
||||
error = '不能为空'
|
||||
|
||||
if len(password) < 6:
|
||||
if len(password) > 0 and len(password) < 6:
|
||||
error = '密码须大于6位'
|
||||
|
||||
if not error:
|
||||
# if password != user.password:
|
||||
# password = CRYPTOR.md5_crypt(password)
|
||||
|
||||
user.update(name=name, email=email)
|
||||
User.objects.filter(id=user_id).update(name=name, email=email)
|
||||
if len(password) > 0:
|
||||
user.set_password(password)
|
||||
user.save()
|
||||
msg = '修改成功'
|
||||
|
||||
return render_to_response('juser/change_info.html', locals(), context_instance=RequestContext(request))
|
||||
|
|
|
@ -0,0 +1,196 @@
|
|||
/* ShiftCheckbox jQuery plugin
|
||||
*
|
||||
* Copyright (C) 2011-2012 James Nylen
|
||||
*
|
||||
* Released under MIT license
|
||||
* For details see:
|
||||
* https://github.com/nylen/shiftcheckbox
|
||||
*
|
||||
* Requires jQuery v1.7 or higher.
|
||||
*/
|
||||
|
||||
(function($) {
|
||||
var ns = '.shiftcheckbox';
|
||||
|
||||
$.fn.shiftcheckbox = function(opts) {
|
||||
opts = $.extend({
|
||||
checkboxSelector : null,
|
||||
selectAll : null,
|
||||
onChange : null,
|
||||
ignoreClick : null
|
||||
}, opts);
|
||||
|
||||
if (typeof opts.onChange != 'function') {
|
||||
opts.onChange = function(checked) { };
|
||||
}
|
||||
|
||||
$.fn.scb_changeChecked = function(opts, checked) {
|
||||
this.prop('checked', checked);
|
||||
opts.onChange.call(this, checked);
|
||||
return this;
|
||||
}
|
||||
|
||||
var $containers,
|
||||
$checkboxes,
|
||||
$containersSelectAll,
|
||||
$checkboxesSelectAll,
|
||||
$otherSelectAll,
|
||||
$containersAll,
|
||||
$checkboxesAll;
|
||||
|
||||
if (opts.selectAll) {
|
||||
// We need to set up a "select all" control
|
||||
$containersSelectAll = $(opts.selectAll);
|
||||
if ($containersSelectAll && !$containersSelectAll.length) {
|
||||
$containersSelectAll = false;
|
||||
}
|
||||
}
|
||||
|
||||
if ($containersSelectAll) {
|
||||
$checkboxesSelectAll = $containersSelectAll
|
||||
.filter(':checkbox')
|
||||
.add($containersSelectAll.find(':checkbox'));
|
||||
|
||||
$containersSelectAll = $containersSelectAll.not(':checkbox');
|
||||
$otherSelectAll = $containersSelectAll.filter(function() {
|
||||
return !$(this).find($checkboxesSelectAll).length;
|
||||
});
|
||||
$containersSelectAll = $containersSelectAll.filter(function() {
|
||||
return !!$(this).find($checkboxesSelectAll).length;
|
||||
}).each(function() {
|
||||
$(this).data('childCheckbox', $(this).find($checkboxesSelectAll)[0]);
|
||||
});
|
||||
}
|
||||
|
||||
if (opts.checkboxSelector) {
|
||||
|
||||
// checkboxSelector means that the elements we need to attach handlers to
|
||||
// ($containers) are not actually checkboxes but contain them instead
|
||||
|
||||
$containersAll = this.filter(function() {
|
||||
return !!$(this).find(opts.checkboxSelector).filter(':checkbox').length;
|
||||
}).each(function() {
|
||||
$(this).data('childCheckbox', $(this).find(opts.checkboxSelector).filter(':checkbox')[0]);
|
||||
}).add($containersSelectAll);
|
||||
|
||||
$checkboxesAll = $containersAll.map(function() {
|
||||
return $(this).data('childCheckbox');
|
||||
});
|
||||
|
||||
} else {
|
||||
|
||||
$checkboxesAll = this.filter(':checkbox');
|
||||
|
||||
}
|
||||
|
||||
if ($checkboxesSelectAll && !$checkboxesSelectAll.length) {
|
||||
$checkboxesSelectAll = false;
|
||||
} else {
|
||||
$checkboxesAll = $checkboxesAll.add($checkboxesSelectAll);
|
||||
}
|
||||
|
||||
if ($otherSelectAll && !$otherSelectAll.length) {
|
||||
$otherSelectAll = false;
|
||||
}
|
||||
|
||||
if ($containersAll) {
|
||||
$containers = $containersAll.not($containersSelectAll);
|
||||
}
|
||||
$checkboxes = $checkboxesAll.not($checkboxesSelectAll);
|
||||
|
||||
if (!$checkboxes.length) {
|
||||
return;
|
||||
}
|
||||
|
||||
var lastIndex = -1;
|
||||
|
||||
var checkboxClicked = function(e) {
|
||||
var checked = !!$(this).prop('checked');
|
||||
|
||||
var curIndex = $checkboxes.index(this);
|
||||
if (curIndex < 0) {
|
||||
if ($checkboxesSelectAll.filter(this).length) {
|
||||
$checkboxesAll.scb_changeChecked(opts, checked);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (e.shiftKey && lastIndex != -1) {
|
||||
var di = (curIndex > lastIndex ? 1 : -1);
|
||||
for (var i = lastIndex; i != curIndex; i += di) {
|
||||
$checkboxes.eq(i).scb_changeChecked(opts, checked);
|
||||
}
|
||||
}
|
||||
|
||||
if ($checkboxesSelectAll) {
|
||||
if (checked && !$checkboxes.not(':checked').length) {
|
||||
$checkboxesSelectAll.scb_changeChecked(opts, true);
|
||||
} else if (!checked) {
|
||||
$checkboxesSelectAll.scb_changeChecked(opts, false);
|
||||
}
|
||||
}
|
||||
|
||||
lastIndex = curIndex;
|
||||
};
|
||||
|
||||
if ($checkboxesSelectAll) {
|
||||
$checkboxesSelectAll
|
||||
.prop('checked', !$checkboxes.not(':checked').length)
|
||||
.filter(function() {
|
||||
return !$containersAll.find(this).length;
|
||||
}).on('click' + ns, checkboxClicked);
|
||||
}
|
||||
|
||||
if ($otherSelectAll) {
|
||||
$otherSelectAll.on('click' + ns, function() {
|
||||
var checked;
|
||||
if ($checkboxesSelectAll) {
|
||||
checked = !!$checkboxesSelectAll.eq(0).prop('checked');
|
||||
} else {
|
||||
checked = !!$checkboxes.eq(0).prop('checked');
|
||||
}
|
||||
$checkboxesAll.scb_changeChecked(opts, !checked);
|
||||
});
|
||||
}
|
||||
|
||||
if (opts.checkboxSelector) {
|
||||
$containersAll.on('click' + ns, function(e) {
|
||||
if ($(e.target).closest(opts.ignoreClick).length) {
|
||||
return;
|
||||
}
|
||||
var $checkbox = $($(this).data('childCheckbox'));
|
||||
$checkbox.not(e.target).each(function() {
|
||||
var checked = !$checkbox.prop('checked');
|
||||
$(this).scb_changeChecked(opts, checked);
|
||||
});
|
||||
|
||||
$checkbox[0].focus();
|
||||
checkboxClicked.call($checkbox, e);
|
||||
|
||||
// If the user clicked on a label inside the row that points to the
|
||||
// current row's checkbox, cancel the event.
|
||||
var $label = $(e.target).closest('label');
|
||||
var labelFor = $label.attr('for');
|
||||
if (labelFor && labelFor == $checkbox.attr('id')) {
|
||||
if ($label.find($checkbox).length) {
|
||||
// Special case: The label contains the checkbox.
|
||||
if ($checkbox[0] != e.target) {
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}).on('mousedown' + ns, function(e) {
|
||||
if (e.shiftKey) {
|
||||
// Prevent selecting text by Shift+click
|
||||
return false;
|
||||
}
|
||||
});
|
||||
} else {
|
||||
$checkboxes.on('click' + ns, checkboxClicked);
|
||||
}
|
||||
|
||||
return this;
|
||||
};
|
||||
})(jQuery);
|
|
@ -41,7 +41,7 @@
|
|||
</div>
|
||||
<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>
|
||||
<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">
|
||||
<span class="help-block m-b-none">
|
||||
|
@ -91,7 +91,7 @@ $('#userForm').validator({
|
|||
|
||||
fields: {
|
||||
"password": {
|
||||
rule: "required;length[6~50]",
|
||||
rule: "length[6~50]",
|
||||
tip: "输入密码",
|
||||
ok: "",
|
||||
msg: {required: "必须填写!"}
|
||||
|
|
|
@ -43,7 +43,7 @@
|
|||
<thead>
|
||||
<tr>
|
||||
<th class="text-center">
|
||||
<input type="checkbox" id="check_all" onclick="checkAll()" name="check_all">
|
||||
<input type="checkbox" id="select_all" name="select_all">
|
||||
</th>
|
||||
<th class="text-center">组名</th>
|
||||
<th class="text-center">成员数目</th>
|
||||
|
@ -55,7 +55,8 @@
|
|||
{% for group in user_groups.object_list %}
|
||||
<tr class="gradeX">
|
||||
<td class="text-center">
|
||||
<input type="checkbox" name="checked" value="{{ group.id }}">
|
||||
<input class="shiftCheckbox"
|
||||
type="checkbox" name="selected" 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>
|
||||
|
@ -83,6 +84,10 @@
|
|||
</div>
|
||||
{% endblock %}
|
||||
|
||||
{% block self_head_css_js %}
|
||||
{% load staticfiles %}
|
||||
<script src="{% static 'js/jquery.shiftcheckbox.js' %}"></script>
|
||||
{% endblock %}
|
||||
{% block self_footer_js %}
|
||||
<script>
|
||||
$(document).ready(function(){
|
||||
|
@ -115,7 +120,13 @@
|
|||
)
|
||||
}
|
||||
|
||||
})
|
||||
});
|
||||
$("tbody tr").shiftcheckbox({
|
||||
checkboxSelector: 'input:checkbox',
|
||||
selectAll: $('#select_all'),
|
||||
ignoreClick: 'a'
|
||||
});
|
||||
$('.shiftCheckbox').shiftcheckbox();
|
||||
});
|
||||
</script>
|
||||
{% endblock %}
|
|
@ -91,10 +91,15 @@
|
|||
|
||||
{% endblock %}
|
||||
{% block self_head_css_js %}
|
||||
{% load staticfiles %}
|
||||
<script src="{% static 'js/jquery.shiftcheckbox.js' %}"></script>
|
||||
{% endblock %}
|
||||
{% block self_footer_js %}
|
||||
<script>
|
||||
$(document).ready(function(){
|
||||
$('.del').click(function(){
|
||||
var row = $(this).closest('tr');
|
||||
if (confirm("确定删除")) {
|
||||
$.get(
|
||||
$(this).attr('value'),
|
||||
{},
|
||||
|
@ -102,7 +107,7 @@
|
|||
row.remove();
|
||||
alert(data);
|
||||
}
|
||||
)
|
||||
)}
|
||||
});
|
||||
|
||||
$('#del_btn').click(function(){
|
||||
|
@ -129,7 +134,13 @@
|
|||
alert(data)
|
||||
}
|
||||
)
|
||||
})
|
||||
});
|
||||
$("tbody tr").shiftcheckbox({
|
||||
checkboxSelector: 'input:checkbox',
|
||||
selectAll: $('#select_all'),
|
||||
ignoreClick: 'a'
|
||||
});
|
||||
$('.shiftCheckbox').shiftcheckbox();
|
||||
});
|
||||
</script>
|
||||
{% endblock %}
|
Loading…
Reference in New Issue