mirror of https://github.com/jumpserver/jumpserver
last bug?
parent
c8d91884c8
commit
86e334e4fa
|
@ -9,6 +9,7 @@ urlpatterns = patterns('',
|
|||
url(r'^search/$', host_search),
|
||||
url(r"^host_detail/$", host_detail),
|
||||
url(r"^dept_host_ajax/$", dept_host_ajax),
|
||||
url(r"^show_all_ajax/$", show_all_ajax),
|
||||
url(r'^idc_add/$', idc_add),
|
||||
url(r'^idc_list/$', idc_list),
|
||||
url(r'^idc_edit/$', idc_edit),
|
||||
|
|
|
@ -105,15 +105,23 @@ def batch_host_edit(host_info, j_user='', j_password=''):
|
|||
groups, depts = [], []
|
||||
is_active = {u'是': '1', u'否': '2'}
|
||||
login_types = {'LDAP': 'L', 'MAP': 'M'}
|
||||
a = Asset.objects.get(id=j_id)
|
||||
if '...' in j_group[0].split():
|
||||
groups = a.bis_group.all()
|
||||
else:
|
||||
for group in j_group[0].split():
|
||||
c = BisGroup.objects.get(name=group.strip())
|
||||
groups.append(c)
|
||||
|
||||
if '...' in j_dept[0].split():
|
||||
depts = a.dept.all()
|
||||
else:
|
||||
for d in j_dept[0].split():
|
||||
p = DEPT.objects.get(name=d.strip())
|
||||
depts.append(p)
|
||||
|
||||
j_type = login_types[j_type]
|
||||
j_idc = IDC.objects.get(name=j_idc)
|
||||
a = Asset.objects.get(id=j_id)
|
||||
if j_type == 'M':
|
||||
if a.password != j_password:
|
||||
j_password = cryptor.decrypt(j_password)
|
||||
|
@ -140,7 +148,6 @@ def batch_host_edit(host_info, j_user='', j_password=''):
|
|||
|
||||
def db_host_delete(request, host_id):
|
||||
""" 删除主机操作 """
|
||||
print host_id
|
||||
if is_group_admin(request) and not validate(request, asset=[host_id]):
|
||||
return httperror(request, '删除失败, 您无权删除!')
|
||||
|
||||
|
@ -197,7 +204,6 @@ def host_add(request):
|
|||
host_info = [j_ip, j_port, j_idc, j_type, j_group, [j_dept], j_active, j_comment]
|
||||
|
||||
if is_group_admin(request) and not validate(request, asset_group=j_group, edept=[j_dept]):
|
||||
print j_dept
|
||||
return httperror(request, u'添加失败,您无权操作!')
|
||||
|
||||
if Asset.objects.filter(ip=str(j_ip)):
|
||||
|
@ -430,8 +436,7 @@ def host_del(request, offset):
|
|||
host_id = request.POST.get(key)
|
||||
db_host_delete(request, host_id)
|
||||
else:
|
||||
host_id = int(offset)
|
||||
db_host_delete(request, host_id)
|
||||
db_host_delete(request, offset)
|
||||
|
||||
return HttpResponseRedirect('/jasset/host_list/')
|
||||
|
||||
|
@ -886,6 +891,16 @@ def dept_host_ajax(request):
|
|||
return my_render('jasset/dept_host_ajax.html', locals(), request)
|
||||
|
||||
|
||||
def show_all_ajax(request):
|
||||
""" 批量修改主机时, 部门和组全部显示 """
|
||||
env = request.GET.get('env', '')
|
||||
get_id = request.GET.get('id', '')
|
||||
host = Asset.objects.filter(id=get_id)
|
||||
if host:
|
||||
host = host[0]
|
||||
return my_render('jasset/show_all_ajax.html', locals(), request)
|
||||
|
||||
|
||||
@require_login
|
||||
def host_search(request):
|
||||
""" 搜索主机 """
|
||||
|
|
|
@ -39,6 +39,7 @@ class SudoPerm(models.Model):
|
|||
class Apply(models.Model):
|
||||
uuid = UUIDField(auto=True)
|
||||
applyer = models.CharField(max_length=20)
|
||||
admin = models.CharField(max_length=20)
|
||||
approver = models.CharField(max_length=20)
|
||||
dept = models.CharField(max_length=20)
|
||||
bisgroup = models.CharField(max_length=500)
|
||||
|
@ -47,6 +48,7 @@ class Apply(models.Model):
|
|||
status = models.IntegerField(max_length=2)
|
||||
date_add = models.DateTimeField(null=True)
|
||||
date_end = models.DateTimeField(null=True)
|
||||
read = models.IntegerField(max_length=2)
|
||||
|
||||
def __unicode__(self):
|
||||
return self.applyer
|
||||
|
|
|
@ -676,6 +676,7 @@ def perm_apply(request):
|
|||
""" 权限申请 """
|
||||
header_title, path1, path2 = u'主机权限申请', u'权限管理', u'申请主机'
|
||||
user_id, username = get_session_user_info(request)[0:2]
|
||||
name = User.objects.get(id=user_id).name
|
||||
dept_id, deptname, dept = get_session_user_info(request)[3:6]
|
||||
perm_host = user_perm_asset_api(username)
|
||||
all_host = Asset.objects.filter(dept=dept)
|
||||
|
@ -687,6 +688,7 @@ def perm_apply(request):
|
|||
egroup = [d for d in all_group if d not in perm_group]
|
||||
|
||||
dept_da = User.objects.filter(dept_id=dept_id, role='DA')
|
||||
admin = User.objects.get(name='admin')
|
||||
|
||||
if request.method == 'POST':
|
||||
applyer = request.POST.get('applyer')
|
||||
|
@ -695,14 +697,16 @@ def perm_apply(request):
|
|||
group = request.POST.getlist('group')
|
||||
hosts = request.POST.getlist('hosts')
|
||||
comment = request.POST.get('comment')
|
||||
if not da:
|
||||
return httperror(request, u'请选择管理员!')
|
||||
da = User.objects.get(id=da)
|
||||
mail_address = da.email
|
||||
mail_title = '%s - 权限申请' % username
|
||||
group_lis = ', '.join(group)
|
||||
hosts_lis = ', '.join(hosts)
|
||||
time_now = datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S')
|
||||
a = Apply.objects.create(applyer=applyer, dept=dept, bisgroup=group, date_add=datetime.datetime.now(),
|
||||
asset=hosts, status=0, comment=comment)
|
||||
a = Apply.objects.create(applyer=applyer, admin=da, dept=dept, bisgroup=group, date_add=datetime.datetime.now(),
|
||||
asset=hosts, status=0, comment=comment, read=0)
|
||||
uuid = a.uuid
|
||||
url = "http://%s:%s/jperm/apply_exec/?uuid=%s" % (SEND_IP, SEND_PORT, uuid)
|
||||
mail_msg = """
|
||||
|
@ -774,9 +778,9 @@ def get_apply_posts(request, status, username, dept_name, keyword=None):
|
|||
posts = post_all.filter(dept=dept_name)
|
||||
elif is_common_user(request):
|
||||
if keyword:
|
||||
posts = post_keyword_all.filter(user=username)
|
||||
posts = post_keyword_all.filter(applyer=username)
|
||||
else:
|
||||
posts = post_all.filter(user=username)
|
||||
posts = post_all.filter(applyer=username)
|
||||
|
||||
return posts
|
||||
|
||||
|
@ -786,7 +790,8 @@ def perm_apply_log(request, offset):
|
|||
""" 申请记录 """
|
||||
header_title, path1, path2 = u'权限申请记录', u'权限管理', u'申请记录'
|
||||
keyword = request.GET.get('keyword', '')
|
||||
username = get_session_user_info(request)[1]
|
||||
user_id = get_session_user_info(request)[0]
|
||||
username = User.objects.get(id=user_id).name
|
||||
dept_name = get_session_user_info(request)[4]
|
||||
status_dic = {'online': 0, 'offline': 1}
|
||||
status = status_dic[offset]
|
||||
|
@ -798,8 +803,17 @@ def perm_apply_log(request, offset):
|
|||
@require_login
|
||||
def perm_apply_info(request):
|
||||
""" 申请信息详情 """
|
||||
uuid = request.GET.get('uuid')
|
||||
post = Apply.objects.get(uuid=uuid)
|
||||
uuid = request.GET.get('uuid', '')
|
||||
post = Apply.objects.filter(uuid=uuid)
|
||||
username = get_session_user_info(request)[1]
|
||||
if post:
|
||||
post = post[0]
|
||||
if post.read == 0 and post.applyer != username:
|
||||
post.read = 1
|
||||
post.save()
|
||||
else:
|
||||
return httperror(request, u'没有这个申请记录!')
|
||||
|
||||
return render_to_response('jperm/perm_apply_info.html', locals(), context_instance=RequestContext(request))
|
||||
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#coding: utf8
|
||||
|
||||
[base]
|
||||
ip = 192.168.0.129
|
||||
ip = 192.168.199.180
|
||||
port = 80
|
||||
key = 88aaaf7ffe3c6c04
|
||||
|
||||
|
@ -16,14 +16,14 @@ database = jumpserver
|
|||
|
||||
[ldap]
|
||||
ldap_enable = 1
|
||||
host_url = ldap://127.0.0.1:389
|
||||
host_url = ldap://192.168.199.180:389
|
||||
base_dn = dc=jumpserver, dc=org
|
||||
root_dn = cn=admin,dc=jumpserver,dc=org
|
||||
root_pw = secret234
|
||||
|
||||
|
||||
[websocket]
|
||||
web_socket_host = 192.168.20.209:3000
|
||||
web_socket_host = 192.168.199.180:3000
|
||||
|
||||
|
||||
[mail]
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
from juser.models import User
|
||||
from jasset.models import Asset
|
||||
from jumpserver.api import *
|
||||
from jperm.models import Apply
|
||||
|
||||
|
||||
def name_proc(request):
|
||||
|
@ -17,6 +18,9 @@ def name_proc(request):
|
|||
user_active_num = dept.user_set.filter(is_active=True).count()
|
||||
host_total_num = dept.asset_set.all().count()
|
||||
host_active_num = dept.asset_set.all().filter(is_active=True).count()
|
||||
|
||||
username = User.objects.get(id=user_id).name
|
||||
apply_info = Apply.objects.filter(admin=username, status=0, read=0)
|
||||
request.session.set_expiry(3600)
|
||||
|
||||
info_dic = {'session_user_id': user_id,
|
||||
|
@ -24,7 +28,8 @@ def name_proc(request):
|
|||
'user_total_num': user_total_num,
|
||||
'user_active_num': user_active_num,
|
||||
'host_total_num': host_total_num,
|
||||
'host_active_num': host_active_num}
|
||||
'host_active_num': host_active_num,
|
||||
'apply_info': apply_info}
|
||||
|
||||
return info_dic
|
||||
|
||||
|
|
|
@ -68,6 +68,15 @@ def group_str2_all(group_list):
|
|||
return '%s ...' % ' '.join([group.name for group in group_lis[0:2]])
|
||||
|
||||
|
||||
@register.filter(name='group_dept_all')
|
||||
def group_dept_all(group_list):
|
||||
group_lis = []
|
||||
for i in group_list:
|
||||
if str(i) != 'ALL':
|
||||
group_lis.append(i)
|
||||
return ' '.join([group.name for group in group_lis])
|
||||
|
||||
|
||||
@register.filter(name='group_manage_str')
|
||||
def group_manage_str(username):
|
||||
user = User.objects.get(username=username)
|
||||
|
|
|
@ -16,7 +16,7 @@ from jlog.models import Log
|
|||
|
||||
def log_hanler(id):
|
||||
log = Log.objects.get(id=id)
|
||||
pattern = re.compile(r'([\[.*@.*\][\$#].* | mysql>.*])')
|
||||
pattern = re.compile(r'([\[.*@.*\][\$#].*)|(.*mysql>.*)')
|
||||
if log:
|
||||
filename = log.log_path
|
||||
if os.path.isfile(filename):
|
||||
|
|
|
@ -62,7 +62,7 @@
|
|||
<td class="text-center"> {{ post.date_added|date:"Y-m-d H:i:s" }} </td>
|
||||
<td class="text-center" name="j_comment"> {{ post.comment }} </td>
|
||||
<td class="text-center" data-editable='false'>
|
||||
<a value="/jasset/{{ post.ip }}/" class="iframe btn btn-xs btn-primary">详情</a>
|
||||
<a href="/jasset/host_detail/?id={{ post.id }}" class="iframe btn btn-xs btn-primary">详情</a>
|
||||
<a href="/jasset/host_edit/?id={{ post.id }}" class="btn btn-xs btn-info">编辑</a>
|
||||
<a href="/jasset/group_del_host/?id={{ post.id }}&gid={{ group.id }}" class="btn btn-xs btn-danger">删除</a>
|
||||
</td>
|
||||
|
|
|
@ -69,7 +69,9 @@
|
|||
<td class="text-center" name="j_type"> {{ post.login_type|get_login_type }} </td>
|
||||
<td class="text-center" name="j_idc"> {{ post.idc.name }} </td>
|
||||
<td class="text-center" name="j_dept">{{ post.dept.all | group_str2 }}</td>
|
||||
<!--<td class="text-center" id="j_dept_{{post.id}}" name="j_dept" onclick="show_all('dept', '{{post.id}}')">{{ post.dept.all | group_str2 }}</td>-->
|
||||
<td class="text-center" name="j_group">{{ post.bis_group.all | group_str2_all }}</td>
|
||||
<!--<td class="text-center" id="j_group_{{post.id}}" name="j_group" onclick="show_all('group', '{{post.id}}')">{{ post.bis_group.all | group_str2_all }}</td>-->
|
||||
<td class="text-center" name="j_active"> {{ post.is_active|bool2str }} </td>
|
||||
<td class="text-center" name="j_comment"> {{ post.comment }} </td>
|
||||
<td class="text-center" data-editable='false'>
|
||||
|
@ -98,13 +100,27 @@
|
|||
</div>
|
||||
|
||||
<script>
|
||||
$('table td').on('change', function(env, id){
|
||||
var url = "/jasset/show_all_ajax/?env=" + env + "&id=" + id;
|
||||
console.log(url);
|
||||
$.ajax({
|
||||
type: "GET",
|
||||
url: url,
|
||||
// data: $("#search_form").serialize(),
|
||||
success: function (data) {
|
||||
$("#j_dept_"+id).html(data);
|
||||
}
|
||||
});
|
||||
})
|
||||
|
||||
$(document).ready(function(){
|
||||
$('#editable').editableTableWidget();
|
||||
$('#editable').editableTableWidget({editor: $('<textarea>')});
|
||||
});
|
||||
|
||||
|
||||
function alter(form) {
|
||||
selectData = GetTableDataBox();
|
||||
console.log(selectData[0])
|
||||
if (selectData[1] != 0) {
|
||||
$.ajax({
|
||||
type: "post",
|
||||
|
@ -113,6 +129,7 @@
|
|||
success: function (data) {
|
||||
alert("修改成功");
|
||||
window.open("/jasset/host_list/", "_self");
|
||||
error: window.open("/jasset/host_list/", "_self");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -157,7 +174,19 @@
|
|||
}
|
||||
})
|
||||
|
||||
function show_all(env, id) {
|
||||
var url = "/jasset/show_all_ajax/?env=" + env + "&id=" + id;
|
||||
console.log(url);
|
||||
$.ajax({
|
||||
type: "GET",
|
||||
url: url,
|
||||
// data: $("#search_form").serialize(),
|
||||
success: function (data) {
|
||||
$("#j_group_" + id).html(data);
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
</script>
|
||||
|
||||
{% endblock %}
|
|
@ -0,0 +1,7 @@
|
|||
{% load mytags %}
|
||||
{% ifequal env 'group' %}
|
||||
{{ host.bis_group.all|group_dept_all }}
|
||||
{% endifequal %}
|
||||
{% ifequal env 'dept' %}
|
||||
{{ host.dept.all|group_dept_all }}
|
||||
{% endifequal %}
|
|
@ -58,7 +58,7 @@
|
|||
<form id="assetForm" method="post" class="form-horizontal">
|
||||
{% csrf_token %}
|
||||
<div class="form-group"><label class="col-sm-2 control-label"> 申请人 <span class="red-fonts">*</span></label>
|
||||
<div class="col-sm-8"><input type="text" name="applyer" value="{{ username }}" class="form-control" readonly="readonly"></div>
|
||||
<div class="col-sm-8"><input type="text" name="applyer" value="{{ name }}" class="form-control" readonly="readonly"></div>
|
||||
</div>
|
||||
|
||||
<div class="hr-line-dashed"></div>
|
||||
|
@ -67,10 +67,11 @@
|
|||
</div>
|
||||
|
||||
<div class="hr-line-dashed"></div>
|
||||
<div class="form-group" id="j_da"><label class="col-sm-2 control-label"> 部门管理员 <span class="red-fonts">*</span></label>
|
||||
<div class="form-group" id="j_da"><label class="col-sm-2 control-label"> 管理员 <span class="red-fonts">*</span></label>
|
||||
<div class="radio">
|
||||
<label><input type="radio" value="{{ admin.id }}" name="da"> {{ admin.name }}</label>
|
||||
{% for da in dept_da %}
|
||||
<label><input type="radio" value="{{ da.id }}" name="da"> {{ da }}</label>
|
||||
<label><input type="radio" value="{{ da.id }}" name="da"> {{ da.name }}</label>
|
||||
{% endfor %}
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
{% load humanize %}
|
||||
{% load mytags %}
|
||||
<nav class="navbar navbar-static-top" role="navigation" style="margin-bottom: 0">
|
||||
<div class="navbar-header">
|
||||
<a class="navbar-minimalize minimalize-styl-2 btn btn-primary " href="#"><i class="fa fa-bars"></i> </a>
|
||||
|
@ -13,55 +15,41 @@
|
|||
</li>
|
||||
<li class="dropdown">
|
||||
<a class="dropdown-toggle count-info" data-toggle="dropdown" href="#">
|
||||
<i class="fa fa-envelope"></i> <span class="label label-warning">{{ message }}</span>
|
||||
<i class="fa fa-envelope"></i> <span class="label label-warning">{{ apply_info.count }}</span>
|
||||
</a>
|
||||
<ul class="dropdown-menu dropdown-messages">
|
||||
{% if apply_info %}
|
||||
{% for apply in apply_info %}
|
||||
<li>
|
||||
<div class="dropdown-messages-box">
|
||||
<a href="profile.html" class="pull-left">
|
||||
<img alt="image" class="img-circle" src="/static/img/a7.jpg">
|
||||
</a>
|
||||
<div class="media-body">
|
||||
<small class="pull-right">46h ago</small>
|
||||
<strong>Mike Loreipsum</strong> started following <strong>Monica Smith</strong>. <br>
|
||||
<small class="text-muted">3 days ago at 7:58 pm - 10.06.2014</small>
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
<li class="divider"></li>
|
||||
<li>
|
||||
<div class="dropdown-messages-box">
|
||||
<a href="profile.html" class="pull-left">
|
||||
<a href="/jperm/apply_show/online/" class="pull-left">
|
||||
<img alt="image" class="img-circle" src="/static/img/a4.jpg">
|
||||
</a>
|
||||
<div class="media-body">
|
||||
<small class="pull-right text-navy">5h ago</small>
|
||||
<strong>Chris Johnatan Overtunk</strong> started following <strong>Monica Smith</strong>. <br>
|
||||
<small class="text-muted">Yesterday 1:21 pm - 11.06.2014</small>
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
<li class="divider"></li>
|
||||
<li>
|
||||
<div class="dropdown-messages-box">
|
||||
<a href="profile.html" class="pull-left">
|
||||
<img alt="image" class="img-circle" src="/static/img/profile.jpg">
|
||||
</a>
|
||||
<div class="media-body ">
|
||||
<small class="pull-right">23h ago</small>
|
||||
<strong>Monica Smith</strong> love <strong>Kim Smith</strong>. <br>
|
||||
<small class="text-muted">2 days ago at 2:30 am - 11.06.2014</small>
|
||||
<small class="pull-right text-navy">{{ apply.date_add|naturaltime }}</small>
|
||||
<strong>{{ apply.applyer }}</strong><br>
|
||||
<small class="text-muted">主机组: {{ apply.bisgroup|ast_to_list }}</small><br/>
|
||||
<small class="text-muted">主机: {{ apply.asset|ast_to_list }}</small><br/>
|
||||
<small class="text-muted">申请时间: {{ apply.date_add|date:"Y-m-d H:i:s" }}</small>
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
<li class="divider"></li>
|
||||
{% endfor %}
|
||||
<li>
|
||||
<div class="text-center link-block">
|
||||
<a href="mailbox.html">
|
||||
<a href="/jperm/apply_show/online/">
|
||||
<i class="fa fa-envelope"></i> <strong>Read All Messages</strong>
|
||||
</a>
|
||||
</div>
|
||||
</li>
|
||||
{% else %}
|
||||
<li>
|
||||
<div class="text-center link-block">
|
||||
<i class="fa fa-envelope"></i> <strong>(暂无通知)</strong>
|
||||
</div>
|
||||
</li>
|
||||
{% endif %}
|
||||
</ul>
|
||||
</li>
|
||||
<li>
|
||||
|
|
|
@ -1 +0,0 @@
|
|||
listening on *:3000
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue