mirror of https://github.com/jumpserver/jumpserver
fix some bug
parent
35c818f4a0
commit
bf23d6d7aa
|
@ -78,39 +78,8 @@ def get_count_by_date(date_li, item):
|
|||
|
||||
@require_role(role='user')
|
||||
def index_cu(request):
|
||||
# user_id = request.user.id
|
||||
# user = get_object(User, id=user_id)
|
||||
login_types = {'L': 'LDAP', 'M': 'MAP'}
|
||||
username = request.user.username
|
||||
# TODO: need fix,liuzheng need Asset help
|
||||
GUP = get_group_user_perm(request.user)
|
||||
print GUP
|
||||
assets = GUP.get('asset')
|
||||
idcs = []
|
||||
for i in assets:
|
||||
if i.idc_id:
|
||||
idcs.append(i.idc_id)
|
||||
idc_all = IDC.objects.filter(id__in=idcs)
|
||||
for i in idc_all:
|
||||
print i.name
|
||||
# idc_all = []
|
||||
# for i in assets:
|
||||
# idc_all.append(i.idc)
|
||||
# print i.idc.name
|
||||
asset_group_all = GUP.get('asset_group')
|
||||
# posts = Asset.object.all()
|
||||
# host_count = len(posts)
|
||||
#
|
||||
# new_posts = []
|
||||
# post_five = []
|
||||
# for post in posts:
|
||||
# if len(post_five) < 5:
|
||||
# post_five.append(post)
|
||||
# else:
|
||||
# new_posts.append(post_five)
|
||||
# post_five = []
|
||||
# new_posts.append(post_five)
|
||||
return render_to_response('index_cu.html', locals(), context_instance=RequestContext(request))
|
||||
return HttpResponseRedirect('/juser/user_detail/')
|
||||
|
||||
|
||||
@require_role(role='user')
|
||||
|
|
|
@ -129,8 +129,8 @@ def gen_ssh_key(username, password='',
|
|||
生成一个用户ssh密钥对
|
||||
"""
|
||||
logger.debug('生成ssh key, 并设置authorized_keys')
|
||||
private_key_file = os.path.join(key_dir, username)
|
||||
mkdir(key_dir, mode=777)
|
||||
private_key_file = os.path.join(key_dir, username, 'pem')
|
||||
mkdir(key_dir, mode=0777)
|
||||
if os.path.isfile(private_key_file):
|
||||
os.unlink(private_key_file)
|
||||
ret = bash('echo -e "y\n"|ssh-keygen -t rsa -f %s -b %s -P "%s"' % (private_key_file, length, password))
|
||||
|
@ -142,7 +142,7 @@ def gen_ssh_key(username, password='',
|
|||
with open(private_key_file+'.pub') as pub_f:
|
||||
with open(authorized_key_file, 'w') as auth_f:
|
||||
auth_f.write(pub_f.read())
|
||||
os.chmod(authorized_key_file, 0600)
|
||||
os.chmod(authorized_key_file, mode=0600)
|
||||
chown(authorized_key_file, username)
|
||||
|
||||
|
||||
|
|
|
@ -162,7 +162,7 @@ def user_add(request):
|
|||
ssh_key_pwd = PyCrypt.gen_rand_pass(16)
|
||||
extra = request.POST.getlist('extra', [])
|
||||
is_active = False if '0' in extra else True
|
||||
ssh_key_login_need = True if '1' in extra else False
|
||||
ssh_key_login_need = True
|
||||
send_mail_need = True if '2' in extra else False
|
||||
|
||||
try:
|
||||
|
@ -191,7 +191,7 @@ def user_add(request):
|
|||
user_groups = []
|
||||
for user_group_id in groups:
|
||||
user_groups.extend(UserGroup.objects.filter(id=user_group_id))
|
||||
print user_groups
|
||||
|
||||
except IndexError, e:
|
||||
error = u'添加用户 %s 失败 %s ' % (username, e)
|
||||
try:
|
||||
|
@ -302,7 +302,7 @@ def forget_password(request):
|
|||
""" % (user.name, URL, user.uuid, timestamp, hash_encode)
|
||||
send_mail('忘记跳板机密码', msg, MAIL_FROM, [email], fail_silently=False)
|
||||
msg = u'请登陆邮箱,点击邮件重设密码'
|
||||
return HttpResponse(msg)
|
||||
return http_success(request, msg)
|
||||
else:
|
||||
error = u'用户不存在或邮件地址错误'
|
||||
|
||||
|
@ -310,10 +310,16 @@ def forget_password(request):
|
|||
|
||||
|
||||
def reset_password(request):
|
||||
uuid = request.GET.get('uuid', '')
|
||||
uuid_r = request.GET.get('uuid', '')
|
||||
timestamp = request.GET.get('timestamp', '')
|
||||
hash_encode = request.GET.get('hash', '')
|
||||
action = '/juser/reset_password/?uuid=%s×tamp=%s&hash=%s' % (uuid, timestamp, hash_encode)
|
||||
action = '/juser/reset_password/?uuid=%s×tamp=%s&hash=%s' % (uuid_r, timestamp, hash_encode)
|
||||
|
||||
if hash_encode == PyCrypt.md5_crypt(uuid_r + timestamp + KEY):
|
||||
if int(time.time()) - int(timestamp) > 600:
|
||||
return http_error(request, u'链接已超时')
|
||||
else:
|
||||
return render_to_response('juser/reset_password.html', locals())
|
||||
|
||||
if request.method == 'POST':
|
||||
password = request.POST.get('password')
|
||||
|
@ -325,16 +331,10 @@ def reset_password(request):
|
|||
if user:
|
||||
user.password = PyCrypt.md5_crypt(password)
|
||||
user.save()
|
||||
return HttpResponse('密码重设成功')
|
||||
return http_success(request, u'密码重设成功')
|
||||
else:
|
||||
return HttpResponse('用户不存在')
|
||||
|
||||
if hash_encode == PyCrypt.md5_crypt(uuid + timestamp + KEY):
|
||||
if int(time.time()) - int(timestamp) > 600:
|
||||
return HttpResponse('链接已超时')
|
||||
else:
|
||||
return render_to_response('juser/reset_password.html', locals())
|
||||
|
||||
return http_error(request, u'错误请求')
|
||||
|
||||
|
||||
|
@ -428,7 +428,8 @@ def change_info(request):
|
|||
|
||||
if '' in [name, email]:
|
||||
error = '不能为空'
|
||||
if len(password) > 0 and len(password) < 6:
|
||||
|
||||
if len(password) < 6:
|
||||
error = '密码须大于6位'
|
||||
|
||||
if not error:
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
<html>
|
||||
|
||||
<head>
|
||||
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
|
||||
|
@ -12,8 +11,6 @@
|
|||
{% include 'link_css.html' %}
|
||||
{% include 'head_script.html' %}
|
||||
{% block self_head_css_js %} {% endblock %}
|
||||
|
||||
|
||||
</head>
|
||||
|
||||
<body>
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<div class="footer fixed">
|
||||
<div class="pull-right">
|
||||
Version <strong>0.2.0</strong> GPL.
|
||||
Version <strong>0.3.0</strong> GPL.
|
||||
</div>
|
||||
<div>
|
||||
<strong>Copyright</strong> Jumpserver.org Team © 2014-2015
|
||||
|
|
|
@ -45,7 +45,7 @@
|
|||
<div class="col-sm-8">
|
||||
<input id="password" name="password" placeholder="Password" type="password" class="form-control">
|
||||
<span class="help-block m-b-none">
|
||||
登陆web的密码
|
||||
登陆web的密码, 不修改请留空
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -88,10 +88,13 @@
|
|||
$('#userForm').validator({
|
||||
timely: 2,
|
||||
theme: "yellow_right_effect",
|
||||
rules: {
|
||||
check_pass: [/^\w+$/, '数字和字符']
|
||||
},
|
||||
|
||||
fields: {
|
||||
"password": {
|
||||
rule: "length[6~50]",
|
||||
rule: "length[6~50];check_pass",
|
||||
tip: "输入密码",
|
||||
ok: "",
|
||||
msg: {required: "必须填写!"}
|
||||
|
|
|
@ -7,21 +7,20 @@
|
|||
|
||||
<link href="/static/css/bootstrap.min.css" rel="stylesheet">
|
||||
<link href="/static/font-awesome/css/font-awesome.css" rel="stylesheet">
|
||||
|
||||
<link href="/static/css/animate.css" rel="stylesheet">
|
||||
<link href="/static/css/style.css" rel="stylesheet">
|
||||
|
||||
|
||||
<style type="text/css"></style></head>
|
||||
|
||||
<body class="gray-bg">
|
||||
|
||||
<div class="lock-word animated fadeInDown">
|
||||
<span class="first-word">Jump</span><span>Server</span>
|
||||
</div>
|
||||
<div class="lock-word animated fadeInDown">
|
||||
<span class="first-word">Jump</span><span>Server</span>
|
||||
</div>
|
||||
<div class="middle-box text-center lockscreen animated fadeInDown">
|
||||
<div>
|
||||
<div class="m-b-md">
|
||||
{# <img alt="image" class="img-circle circle-border" src="https://s3.amazonaws.com/uifaces/faces/twitter/ok/128.jpg">#}
|
||||
{% if error %}
|
||||
<div class="alert alert-warning text-center">{{ error }}</div>
|
||||
{% endif %}
|
||||
|
@ -30,7 +29,7 @@
|
|||
{% endif %}
|
||||
</div>
|
||||
<h3>请输入新密码</h3>
|
||||
<form class="m-t" role="form" action="{{ action }}" method="post">
|
||||
<form class="m-t" role="form" id="restForm" action="{{ action }}" method="post">
|
||||
<div class="form-group">
|
||||
<input type="password" name='password' class="form-control" placeholder="New Password" required="">
|
||||
<input type="password" name='password_confirm' class="form-control" placeholder="Password Confirm" required="">
|
||||
|
@ -39,12 +38,33 @@
|
|||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Mainly scripts -->
|
||||
<script src="/static/js/jquery-2.1.1.js"></script>
|
||||
<script src="/static/js/bootstrap.min.js"></script>
|
||||
<script src="/static/js/validator/jquery.validator.js"></script>
|
||||
<script>
|
||||
$('#restForm').validator({
|
||||
timely: 2,
|
||||
theme: "yellow_right_effect",
|
||||
rules: {
|
||||
check_pass: [/^\w+$/, '数字和字符']
|
||||
},
|
||||
|
||||
|
||||
|
||||
|
||||
</body></html>
|
||||
fields: {
|
||||
"password": {
|
||||
rule: "length[6~50];check_pass",
|
||||
tip: "输入密码",
|
||||
ok: "",
|
||||
msg: {required: "必须填写!"}
|
||||
},
|
||||
'password_confirm': {
|
||||
rule: "match[password]"
|
||||
}
|
||||
},
|
||||
valid: function(form) {
|
||||
form.submit();
|
||||
}
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
|
@ -99,11 +99,11 @@
|
|||
<label><input type="checkbox" value="0" name="extra" >禁用 </label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-sm-2">
|
||||
<div class="checkbox i-checks">
|
||||
<label><input type="checkbox" value="1" name="extra">ssh key登录 </label>
|
||||
</div>
|
||||
</div>
|
||||
{# <div class="col-sm-2">#}
|
||||
{# <div class="checkbox i-checks">#}
|
||||
{# <label><input type="checkbox" value="1" name="extra">ssh key登录 </label>#}
|
||||
{# </div>#}
|
||||
{# </div>#}
|
||||
<div class="col-sm-2">
|
||||
<div class="checkbox i-checks">
|
||||
<label><input type="checkbox" value="2" name="extra">发送邮件 </label>
|
||||
|
@ -167,16 +167,16 @@ $('#userForm').validator({
|
|||
}
|
||||
});
|
||||
|
||||
$("document").ready(function(){
|
||||
$("input.role").click(function(){
|
||||
if($("input.role[value=GA]").is( ":checked" )){
|
||||
$("#admin_groups").css("display", 'block');
|
||||
}
|
||||
else {
|
||||
$("#admin_groups").css("display", 'none');
|
||||
}
|
||||
})
|
||||
})
|
||||
{#$("document").ready(function(){#}
|
||||
{# $("input.role").click(function(){#}
|
||||
{# if($("input.role[value=GA]").is( ":checked" )){#}
|
||||
{# $("#admin_groups").css("display", 'block');#}
|
||||
{# }#}
|
||||
{# else {#}
|
||||
{# $("#admin_groups").css("display", 'none');#}
|
||||
{# }#}
|
||||
{# })#}
|
||||
{#})#}
|
||||
|
||||
</script>
|
||||
{% endblock %}
|
|
@ -45,9 +45,17 @@
|
|||
<td>{{ user.name }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="text-navy">角色</td>
|
||||
<td class="text-navy">权限</td>
|
||||
<td>{{ user.id | get_role }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="text-navy">key</td>
|
||||
{% if user.username|key_exist %}
|
||||
<td><a href="/juser/down_key/?id={{ user.id }}" >下载</a></td>
|
||||
{% else %}
|
||||
<td><span style="color: #586b7d">下载</span></td>
|
||||
{% endif %}
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="text-navy">Email</td>
|
||||
<td>{{ user.email }}</td>
|
||||
|
|
|
@ -140,13 +140,9 @@
|
|||
$('#userForm').validator({
|
||||
timely: 2,
|
||||
theme: "yellow_right_effect",
|
||||
{# rules: {#}
|
||||
{# check_ip: [/^(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])(\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])){3}$/, 'ip地址不正确'],#}
|
||||
{# check_port: [/^\d{1,5}$/, '端口号不正确'],#}
|
||||
{# type_m: function (element) {#}
|
||||
{# return $("#M").is(":checked");#}
|
||||
{# }#}
|
||||
{# },#}
|
||||
rules: {
|
||||
check_pass: [/^\w+$/, '数字和字符']
|
||||
},
|
||||
fields: {
|
||||
"username": {
|
||||
rule: "required",
|
||||
|
@ -155,7 +151,7 @@ $('#userForm').validator({
|
|||
msg: {required: "必须填写!"}
|
||||
},
|
||||
"password": {
|
||||
rule: "length[6~50]",
|
||||
rule: "length[6~50];check_pass",
|
||||
tip: "输入密码",
|
||||
ok: "",
|
||||
msg: {required: "必须填写!"}
|
||||
|
|
|
@ -62,8 +62,8 @@
|
|||
<div class="sidebar-collapse">
|
||||
<ul class="nav" id="side-menu">
|
||||
{% include 'nav_li_profile.html' %}
|
||||
<li id="index">
|
||||
<a href="/"><i class="fa fa-dashboard"></i> <span class="nav-label">仪表盘</span><span class="label label-info pull-right"></span></a>
|
||||
<li id="juser">
|
||||
<a href="/juser/user_detail/"><i class="fa fa-dashboard"></i> <span class="nav-label">仪表盘</span><span class="label label-info pull-right"></span></a>
|
||||
</li>
|
||||
<li id="jasset">
|
||||
<a href="/jasset/asset_list/"><i class="fa fa-inbox"></i> <span class="nav-label">查看主机</span><span class="label label-info pull-right"></span></a>
|
||||
|
|
|
@ -17,13 +17,13 @@
|
|||
<ul class="dropdown-menu animated fadeInRight m-t-xs">
|
||||
<li><a value="/juser/profile/?id={{ session_user_id }}" class="iframe_user">个人信息</a></li>
|
||||
<li><a href="/juser/change_info/">修改信息</a></li>
|
||||
{% if not user.role == 'CU' %}
|
||||
{% if request.session.role_id == 0 %}
|
||||
<li><a href="/juser/change_role/">系统后台</a></li>
|
||||
{% else %}
|
||||
<li><a href="/juser/change_role/">主机控制台</a></li>
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
{# {% if not user.role == 'CU' %}#}
|
||||
{# {% if request.session.role_id == 0 %}#}
|
||||
{# <li><a href="/juser/change_role/">系统后台</a></li>#}
|
||||
{# {% else %}#}
|
||||
{# <li><a href="/juser/change_role/">主机控制台</a></li>#}
|
||||
{# {% endif %}#}
|
||||
{# {% endif %}#}
|
||||
<li class="divider"></li>
|
||||
<li><a href="/logout/">注销</a></li>
|
||||
</ul>
|
||||
|
|
|
@ -1,85 +0,0 @@
|
|||
<html>
|
||||
<body>
|
||||
<div id="main" style="height:400px;"></div>
|
||||
...
|
||||
<script src="/static/js/echarts/echarts.js"></script>
|
||||
<script type="text/javascript">
|
||||
require.config({
|
||||
paths: {
|
||||
'echarts': '/static/js/echarts/chart',
|
||||
'echarts/chart/line': '/static/js/echarts/chart/line'
|
||||
}
|
||||
});
|
||||
require(
|
||||
[
|
||||
'echarts',
|
||||
'echarts/chart/line'
|
||||
],
|
||||
function (ec) {
|
||||
var myChart = ec.init(document.getElementById('main'));
|
||||
var option = {
|
||||
title : {
|
||||
text: '某楼盘销售情况',
|
||||
subtext: '纯属虚构'
|
||||
},
|
||||
tooltip : {
|
||||
trigger: 'axis'
|
||||
},
|
||||
legend: {
|
||||
data:['意向','预购','成交']
|
||||
},
|
||||
toolbox: {
|
||||
show : true,
|
||||
feature : {
|
||||
mark : {show: true},
|
||||
dataView : {show: true, readOnly: false},
|
||||
magicType : {show: true, type: ['line', 'bar', 'stack', 'tiled']},
|
||||
restore : {show: true},
|
||||
saveAsImage : {show: true}
|
||||
}
|
||||
},
|
||||
calculable : true,
|
||||
xAxis : [
|
||||
{
|
||||
type : 'category',
|
||||
boundaryGap : false,
|
||||
data : ['周一','周二','周三','周四','周五','周六','周日']
|
||||
}
|
||||
],
|
||||
yAxis : [
|
||||
{
|
||||
type : 'value'
|
||||
}
|
||||
],
|
||||
series : [
|
||||
{
|
||||
name:'成交',
|
||||
type:'line',
|
||||
smooth:true,
|
||||
itemStyle: {normal: {areaStyle: {type: 'default'}}},
|
||||
data:[10, 12, 21, 54, 260, 830, 710]
|
||||
},
|
||||
{
|
||||
name:'预购',
|
||||
type:'line',
|
||||
smooth:true,
|
||||
itemStyle: {normal: {areaStyle: {type: 'default'}}},
|
||||
data:[30, 182, 434, 791, 390, 30, 10]
|
||||
},
|
||||
{
|
||||
name:'意向',
|
||||
type:'line',
|
||||
smooth:true,
|
||||
itemStyle: {normal: {areaStyle: {type: 'default'}}},
|
||||
data:[1320, 1132, 601, 234, 120, 90, 20]
|
||||
}
|
||||
]
|
||||
};
|
||||
|
||||
|
||||
myChart.setOption(option);
|
||||
}
|
||||
);
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
Loading…
Reference in New Issue