合并简单

pull/6/head
ibuler 2015-04-18 16:58:16 +08:00
parent 0873211d13
commit c1d8de4558
16 changed files with 50 additions and 47 deletions

View File

@ -1,7 +1,11 @@
# coding: utf-8 # coding: utf-8
import socket
import sys import sys
reload(sys)
sys.setdefaultencoding('utf8')
import socket
import os import os
import re import re
import ast import ast
@ -218,6 +222,7 @@ def print_user_host(username):
hosts.sort() hosts.sort()
for ip in hosts: for ip in hosts:
print '%-15s -- %s' % (ip, hosts_attr[ip][2]) print '%-15s -- %s' % (ip, hosts_attr[ip][2])
print ''
def print_user_hostgroup(username): def print_user_hostgroup(username):

View File

@ -4,8 +4,6 @@ import ast
from django.db.models import Q from django.db.models import Q
from django.template import RequestContext from django.template import RequestContext
from django.shortcuts import render_to_response
from jperm.models import Perm from jperm.models import Perm
from jumpserver.api import * from jumpserver.api import *
@ -20,11 +18,6 @@ def my_render(template, data, request):
return render_to_response(template, data, context_instance=RequestContext(request)) return render_to_response(template, data, context_instance=RequestContext(request))
def httperror(request, emg):
message = emg
return render_to_response('error.html', locals(), context_instance=RequestContext(request))
def get_host_groups(groups): def get_host_groups(groups):
""" 鑾峰彇涓绘満鎵灞炵殑缁勭被 """ """ 鑾峰彇涓绘満鎵灞炵殑缁勭被 """
ret = [] ret = []
@ -832,7 +825,7 @@ def dept_host_ajax(request):
else: else:
hosts = Asset.objects.all() hosts = Asset.objects.all()
return my_render('jasset/dept_host_ajax.html', locals()) return my_render('jasset/dept_host_ajax.html', locals(), request)
@require_login @require_login

View File

@ -187,18 +187,15 @@ def perm_edit_adm(request):
@require_admin @require_admin
def perm_detail(request): def perm_detail(request):
header_title, path1, path2 = u'缂栬緫鎺堟潈', u'鎺堟潈绠$悊', u'鎺堟潈璇︽儏' header_title, path1, path2 = u'缂栬緫鎺堟潈', u'鎺堟潈绠$悊', u'鎺堟潈璇︽儏'
perm_id = request.GET.get('id') group_id = request.GET.get('id')
perm = Perm.objects.filter(id=perm_id) user_group = UserGroup.objects.filter(id=group_id)
if perm: if user_group:
perm = perm[0] user_group = user_group[0]
user_groups = perm.user_group.all() users_list = user_group.user_set.all()
asset_groups = perm.asset_group.all() perms = user_group.perm_set.all()
asset_groups = [perm.asset_group for perm in perms]
users_list = []
assets_list = [] assets_list = []
for user_group in user_groups:
users_list.extend(user_group.user_set.all())
for asset_group in asset_groups: for asset_group in asset_groups:
assets_list.extend(asset_group.asset_set.all()) assets_list.extend(asset_group.asset_set.all())
@ -478,7 +475,7 @@ def sudo_refresh(request):
asset_groups_select = sudo_perm.asset_group.all() asset_groups_select = sudo_perm.asset_group.all()
cmd_groups_select = sudo_perm.cmd_group.all() cmd_groups_select = sudo_perm.cmd_group.all()
sudo_ldap_add(user_group, user_runas, asset_groups_select, cmd_groups_select) sudo_ldap_add(user_group, user_runas, asset_groups_select, cmd_groups_select)
return HttpResponse('ok') return HttpResponse('鍒锋柊sudo鎺堟潈鎴愬姛')
# @require_admin # @require_admin
@ -652,7 +649,11 @@ def cmd_detail(request):
cmd_ids = request.GET.get('id').split(',') cmd_ids = request.GET.get('id').split(',')
cmds = [] cmds = []
if len(cmd_ids) == 1: if len(cmd_ids) == 1:
cmd_group = CmdGroup.objects.filter(id=cmd_ids[0]) if cmd_ids[0]:
cmd_id = cmd_ids[0]
else:
cmd_id = 1
cmd_group = CmdGroup.objects.filter(id=cmd_id)
if cmd_group: if cmd_group:
cmd_group = cmd_group[0] cmd_group = cmd_group[0]
cmds.extend(cmd_group.cmd.split(',')) cmds.extend(cmd_group.cmd.split(','))

View File

@ -6,7 +6,6 @@ port = 80
key = 88aaaf7ffe3c6c04 key = 88aaaf7ffe3c6c04
[db] [db]
host = 127.0.0.1 host = 127.0.0.1
port = 3306 port = 3306
@ -17,14 +16,14 @@ database = jumpserver
[ldap] [ldap]
ldap_enable = 1 ldap_enable = 1
host_url = ldap://192.168.0.129:389 host_url = ldap://127.0.0.1:389
base_dn = dc=jumpserver, dc=org base_dn = dc=jumpserver, dc=org
root_dn = cn=admin,dc=jumpserver,dc=org root_dn = cn=admin,dc=jumpserver,dc=org
root_pw = secret234 root_pw = secret234
[websocket] [websocket]
web_socket_host = 192.168.0.129:3000 web_socket_host = 192.168.20.209:3000
[mail] [mail]

View File

@ -487,3 +487,7 @@ def is_dir(dir_name, username='root', mode=0755):
def success(request, msg): def success(request, msg):
return render_to_response('success.html', locals()) return render_to_response('success.html', locals())
def httperror(request, emg):
message = emg
return render_to_response('error.html', locals())

View File

@ -231,16 +231,19 @@ def filter_ajax_api(request):
def install(request): def install(request):
from juser.models import DEPT, User from juser.models import DEPT, User
dept = DEPT(id=1, name="瓒呯閮", comment="SUPER DEPT") if User.objects.filter(id=5000):
return httperror(request, 'Jumpserver宸插垵濮嬪寲涓嶈兘閲嶅瀹夎')
dept = DEPT(id=1, name="瓒呯閮", comment="瓒呯骇绠$悊閮ㄩ棬")
dept.save() dept.save()
dept2 = DEPT(id=2, name="榛樿", comment="DEFAULT DEPT") dept2 = DEPT(id=2, name="榛樿", comment="榛樿閮ㄩ棬")
dept2.save() dept2.save()
IDC(id=1, name="榛樿", comment="DEFAULT IDC").save() IDC(id=1, name="榛樿", comment="榛樿IDC").save()
BisGroup(id=1, name="ALL", dept=dept, comment="ALL USER GROUP").save() BisGroup(id=1, name="ALL", dept=dept, comment="鎵鏈変富鏈虹粍").save()
User(id=5000, username="admin", password=md5_crypt('admin'), User(id=5000, username="admin", password=md5_crypt('admin'),
name='admin', email='admin@jumpserver.org', role='SU', is_active=True, dept=dept).save() name='admin', email='admin@jumpserver.org', role='SU', is_active=True, dept=dept).save()
return success(request, u'瀹夎鎴愬姛') return success(request, u'Jumpserver鍒濆鍖鎴愬姛')
def download(request): def download(request):

View File

@ -25,7 +25,7 @@
<h3 id="jumpTo" class="font-bold text-info"></h3> <h3 id="jumpTo" class="font-bold text-info"></h3>
<div class="error-desc"> <div class="error-desc">
The server encountered something unexpected that didn't allow it to complete the request. We apologize.<br/> The server encountered something unexpected that didn't allow it to complete the request. We apologize.<br/>
You can go back to main page: <br/><a href="/" class="btn btn-primary m-t">Dashboard</a> You can go back to main page: <br/><a href="/" class="btn btn-primary m-t">棣栭〉</a>
</div> </div>
</div> </div>

View File

@ -196,7 +196,8 @@
$.get('/jasset/dept_host_ajax/', $.get('/jasset/dept_host_ajax/',
{'id': dept_id}, {'id': dept_id},
function(data){ function(data){
$('#hosts').html(data) $('#assets').html(data)
$('#assets_total').html(data)
}) })
} }

View File

@ -205,7 +205,7 @@
$.get('/jasset/dept_host_ajax/', $.get('/jasset/dept_host_ajax/',
{'id': dept_id}, {'id': dept_id},
function(data){ function(data){
$('#hosts').html(data) $('#assets').html(data)
}) })
} }
</script> </script>

View File

@ -153,7 +153,8 @@
var regx = /\x1B\[([0-9]{1,3}((;[0-9]{1,3})*)?)?[m|K]/g; var regx = /\x1B\[([0-9]{1,3}((;[0-9]{1,3})*)?)?[m|K]/g;
// tag.append('<p>'+escapeString(obj.content.replace(regx,''))+'</p>'); // tag.append('<p>'+escapeString(obj.content.replace(regx,''))+'</p>');
if (option == 'new') { if (option == 'new') {
tag.append('<p style="margin: 2px">' + escapeString(obj.content) + '</p>'); // tag.append('<p style="margin: 2px">' + escapeString(obj.content) + '</p>');
tag.append('<p>'+escapeString(obj.content.replace(regx,' '))+'</p>');
} else if (option == 'exist') { } else if (option == 'exist') {
tag.append('<pre>' + exsit_message + '</pre>'); tag.append('<pre>' + exsit_message + '</pre>');
} }
@ -208,7 +209,7 @@
$.ajax({ $.ajax({
type: "GET", type: "GET",
url: g_url, url: g_url,
success: window.open("/jlog/log_list/online/", "_self") success: window.open("/jlog/log_list/online/", "_self"),
error: window.open(g_url, "_self") error: window.open(g_url, "_self")
}); });

View File

@ -89,7 +89,7 @@
<td>{{ asset.ip }}</td> <td>{{ asset.ip }}</td>
<td>{{ asset.idc.name }}</td> <td>{{ asset.idc.name }}</td>
<td> <td>
{% for group in asset.bis_group.all|filter_private %} {% for group in asset.bis_group.all %}
{{ group }} {{ group }}
{% endfor %} {% endfor %}
</td> </td>

View File

@ -65,6 +65,7 @@
<td class="text-center"> <a href="/jasset/host_list/?gid={{ group.id }}">{{ group.id | ugrp_perm_asset_count }} </a> </td> <td class="text-center"> <a href="/jasset/host_list/?gid={{ group.id }}">{{ group.id | ugrp_perm_asset_count }} </a> </td>
<td class="text-center"> {{ group.comment }} </td> <td class="text-center"> {{ group.comment }} </td>
<td class="text-center"> <td class="text-center">
<a href="../perm_detail/?id={{ group.id }}" class="btn btn-xs btn-primary">璇︽儏</a>
<a href="../perm_edit/?id={{ group.id }}" class="btn btn-xs btn-danger">鎺堟潈缂栬緫</a> <a href="../perm_edit/?id={{ group.id }}" class="btn btn-xs btn-danger">鎺堟潈缂栬緫</a>
</td> </td>
</tr> </tr>

View File

@ -67,13 +67,13 @@
<td class="text-center"> {{ dept.name }} </td> <td class="text-center"> {{ dept.name }} </td>
<td class="text-center"> <a href="/juser/group_list/?did={{ dept.id }}">{{ dept.id | dept_group_num }}</a> </td> <td class="text-center"> <a href="/juser/group_list/?did={{ dept.id }}">{{ dept.id | dept_group_num }}</a> </td>
<td class="text-center"> <a href="/juser/user_list/?did={{ dept.id }}">{{ dept.id | dept_user_num}} </a> </td> <td class="text-center"> <a href="/juser/user_list/?did={{ dept.id }}">{{ dept.id | dept_user_num}} </a> </td>
<td class="text-center"> {{ dept.id | dept_asset_num}} </td> <td class="text-center"> <a href="/jasset/host_list/?did={{ dept.id }}">{{ dept.id | dept_asset_num}} </a> </td>
<td class="text-center"> {{ dept.comment }} </td> <td class="text-center"> {{ dept.comment }} </td>
<td class="text-center"> <td class="text-center">
{# <a href="../dept_detail/?id={{ dept.id }}" class="btn btn-xs btn-primary">璇︽儏</a>#} {# <a href="../dept_detail/?id={{ dept.id }}" class="btn btn-xs btn-primary">璇︽儏</a>#}
{% ifequal session_role_id 2 %} {% ifequal session_role_id 2 %}
<a href="../dept_edit/?id={{ dept.id }}" class="btn btn-xs btn-info">缂栬緫</a> <a href="../dept_edit/?id={{ dept.id }}" class="btn btn-xs btn-info">缂栬緫</a>
<a href="../dept_del/?id={{ dept.id }}" class="btn btn-xs btn-danger {% if dept.id < 3 %} disabled {% endif %} } ">鍒犻櫎</a> <a href="../dept_del/?id={{ dept.id }}" class="btn btn-xs btn-danger {% if dept.id < 3 %} disabled {% endif %} ">鍒犻櫎</a>
{% else %} {% else %}
<a href="../dept_edit/?id={{ dept.id }}" class="btn btn-xs btn-info disabled">缂栬緫</a> <a href="../dept_edit/?id={{ dept.id }}" class="btn btn-xs btn-info disabled">缂栬緫</a>
<a href="../dept_del/?id={{ dept.id }}" class="btn btn-xs btn-danger disabled">鍒犻櫎</a> <a href="../dept_del/?id={{ dept.id }}" class="btn btn-xs btn-danger disabled">鍒犻櫎</a>

View File

@ -74,7 +74,7 @@
<table class="table"> <table class="table">
{% for group in user.group.all %} {% for group in user.group.all %}
<tr> <tr>
<td>{{ group.name }}</td> <td><a href="/jperm/perm_edit/?id={{ group.id }}">{{ group.name }}</a></td>
</tr> </tr>
{% endfor %} {% endfor %}
</table> </table>
@ -152,7 +152,6 @@
</div> </div>
</div> </div>
<div class="ibox-content"> <div class="ibox-content">
<div id="last"> <div id="last">
<div class="feed-activity-list" > <div class="feed-activity-list" >
{% for log in logs_last %} {% for log in logs_last %}
@ -168,19 +167,17 @@
</div> </div>
{% endfor %} {% endfor %}
{% if not logs_last %} {% if not logs_last %}
(鏃) (鏃)
{% endif %} {% endif %}
</div> </div>
{% if logs_num > 10 %} {% if logs_num > 10 %}
<button id="show" class="btn btn-primary btn-block m-t"><i class="fa fa-arrow-down"></i> Show All</button> <button id="show" class="btn btn-primary btn-block m-t"><i class="fa fa-arrow-down"></i> Show All</button>
{% endif %} {% endif %}
</div> </div>
<div id="all" style="display: none"> <div id="all" style="display: none">
<div class="feed-activity-list" > <div class="feed-activity-list" >
{% for log in logs_all %} {% for log in logs_all %}
<div class="feed-element"> <div class="feed-element">
<a href="profile.html" class="pull-left"> <a href="profile.html" class="pull-left">
<img alt="image" class="img-circle" src="/static/img/{{ session_role_id | to_avatar }}.png"> <img alt="image" class="img-circle" src="/static/img/{{ session_role_id | to_avatar }}.png">
@ -189,10 +186,8 @@
<small class="pull-right">{{ log.start_time|time_delta }}</small> <small class="pull-right">{{ log.start_time|time_delta }}</small>
<strong>{{ log.user }}</strong> 鐧诲綍浜 <span class="text-navy">{{ log.host }}. </span><br> <strong>{{ log.user }}</strong> 鐧诲綍浜 <span class="text-navy">{{ log.host }}. </span><br>
<small class="text-muted">{{ log.start_time|date:"Y-m-d H:i:s" }}</small> <small class="text-muted">{{ log.start_time|date:"Y-m-d H:i:s" }}</small>
</div> </div>
</div> </div>
{% endfor %} {% endfor %}
</div> </div>

View File

@ -35,7 +35,7 @@
<a href="/jperm/dept_perm_list/">閮ㄩ棬鎺堟潈</a> <a href="/jperm/dept_perm_list/">閮ㄩ棬鎺堟潈</a>
</li> </li>
<li class="perm_list perm_edit "> <li class="perm_list perm_edit perm_detail ">
<a href="/jperm/perm_list/">灏忕粍鎺堟潈</a> <a href="/jperm/perm_list/">灏忕粍鎺堟潈</a>
</li> </li>
@ -87,7 +87,7 @@
<li id="jperm"> <li id="jperm">
<a href="#"><i class="fa fa-edit"></i> <span class="nav-label">鎺堟潈绠$悊</span><span class="fa arrow"></span></a> <a href="#"><i class="fa fa-edit"></i> <span class="nav-label">鎺堟潈绠$悊</span><span class="fa arrow"></span></a>
<ul class="nav nav-second-level"> <ul class="nav nav-second-level">
<li class="perm_list perm_edit"> <li class="perm_list perm_edit perm_detail">
<a href="/jperm/perm_list/">灏忕粍鎺堟潈</a> <a href="/jperm/perm_list/">灏忕粍鎺堟潈</a>
</li> </li>

View File

@ -25,7 +25,7 @@
<div class="error-desc"> <div class="error-desc">
The server success response the request. Congratulations.<br/> The server success response the request. Congratulations.<br/>
You can go back to main page: <br/><a href="/" class="btn btn-primary m-t">浠〃鐩</a> You can go back to main page: <br/><a href="/" class="btn btn-primary m-t">棣栭〉</a>
</div> </div>
</div> </div>