pull/6/head
ibuler 2015-04-18 18:04:01 +08:00
parent 9ab855fd92
commit 6d6e9d97b5
7 changed files with 27 additions and 24 deletions

View File

@ -338,9 +338,12 @@ def host_list(request):
Q(bis_group__name__contains=keyword) | Q(bis_group__name__contains=keyword) |
Q(comment__contains=keyword)).distinct().order_by('ip') Q(comment__contains=keyword)).distinct().order_by('ip')
if did: if did:
if is_common_user(request) or is_group_admin(request): if is_common_user(request):
return httperror(request, u'鎮ㄦ棤鏉冩煡鐪!') return httperror(request, u'鎮ㄦ棤鏉冩煡鐪!')
if is_group_admin(request):
user, dept = get_session_user_dept(request)
else:
dept = DEPT.objects.get(id=did) dept = DEPT.objects.get(id=did)
posts = dept.asset_set.all() posts = dept.asset_set.all()
return my_render('jasset/host_list_nop.html', locals(), request) return my_render('jasset/host_list_nop.html', locals(), request)

View File

@ -176,8 +176,9 @@ def perm_edit_adm(request):
else: else:
user_group_id = request.POST.get('user_group_id') user_group_id = request.POST.get('user_group_id')
asset_group_id_list = request.POST.getlist('asset_groups_select') asset_group_id_list = request.POST.getlist('asset_groups_select')
print user_group_id, asset_group_id_list
if not validate(request, user_group=[user_group_id], asset_group=asset_group_id_list): if not validate(request, user_group=[user_group_id], asset_group=asset_group_id_list):
return HttpResponseRedirect('/jperm/perm_list/') return HttpResponseRedirect('/')
perm_group_update(user_group_id, asset_group_id_list) perm_group_update(user_group_id, asset_group_id_list)
return HttpResponseRedirect('/jperm/perm_list/') return HttpResponseRedirect('/jperm/perm_list/')

View File

@ -383,9 +383,9 @@ def get_connect_item(username, ip):
def validate(request, user_group=None, user=None, asset_group=None, asset=None, edept=None): def validate(request, user_group=None, user=None, asset_group=None, asset=None, edept=None):
dept = get_session_user_dept(request)[1] dept = get_session_user_dept(request)[1]
if edept: if edept:
if dept.name != edept[0]: print dept.id, edept[0]
if dept.id != int(edept[0]):
return False return False
if user_group: if user_group:
dept_user_groups = dept.usergroup_set.all() dept_user_groups = dept.usergroup_set.all()
user_group_ids = [] user_group_ids = []
@ -398,8 +398,8 @@ def validate(request, user_group=None, user=None, asset_group=None, asset=None,
if user: if user:
dept_users = dept.user_set.all() dept_users = dept.user_set.all()
user_ids = [] user_ids = []
for user in dept_users: for dept_user in dept_users:
user_ids.append(str(user.id)) user_ids.append(str(dept_user.id))
if not set(user).issubset(set(user_ids)): if not set(user).issubset(set(user_ids)):
return False return False
@ -408,7 +408,7 @@ def validate(request, user_group=None, user=None, asset_group=None, asset=None,
dept_asset_groups = dept.bisgroup_set.all() dept_asset_groups = dept.bisgroup_set.all()
asset_group_ids = [] asset_group_ids = []
for group in dept_asset_groups: for group in dept_asset_groups:
asset_group_ids.append(group.id) asset_group_ids.append(str(group.id))
if not set(asset_group).issubset(set(asset_group_ids)): if not set(asset_group).issubset(set(asset_group_ids)):
return False return False
@ -416,8 +416,8 @@ def validate(request, user_group=None, user=None, asset_group=None, asset=None,
if asset: if asset:
dept_assets = dept.asset_set.all() dept_assets = dept.asset_set.all()
asset_ids = [] asset_ids = []
for asset in dept_assets: for dept_asset in dept_assets:
asset_ids.append(str(asset.id)) asset_ids.append(str(dept_asset.id))
if not set(asset).issubset(set(asset_ids)): if not set(asset).issubset(set(asset_ids)):
return False return False
@ -453,7 +453,7 @@ def verify(request, user_group=None, user=None, asset_group=None, asset=None, ed
dept_asset_groups = dept.bisgroup_set.all() dept_asset_groups = dept.bisgroup_set.all()
asset_group_ids = [] asset_group_ids = []
for group in dept_asset_groups: for group in dept_asset_groups:
asset_group_ids.append(group.id) asset_group_ids.append(str(group.id))
if not set(asset_group).issubset(set(asset_group_ids)): if not set(asset_group).issubset(set(asset_group_ids)):
return False return False
@ -465,7 +465,6 @@ def verify(request, user_group=None, user=None, asset_group=None, asset=None, ed
dept_assets_id.append(int(a.id)) dept_assets_id.append(int(a.id))
for i in asset: for i in asset:
assets_id.append(int(i)) assets_id.append(int(i))
print assets_id, dept_assets_id
if not set(assets_id).issubset(dept_assets_id): if not set(assets_id).issubset(dept_assets_id):
return False return False

View File

@ -692,7 +692,7 @@ def user_add_adm(request):
pass pass
else: else:
try: try:
db_add_user(username=username, user = db_add_user(username=username,
password=md5_crypt(password), password=md5_crypt(password),
name=name, email=email, dept=dept, name=name, email=email, dept=dept,
groups=groups, role='CU', groups=groups, role='CU',

View File

@ -16,7 +16,7 @@ from jlog.models import Log
def log_hanler(id): def log_hanler(id):
log = Log.objects.get(id=id) log = Log.objects.get(id=id)
pattern = re.compile(r'(\[.*@.*\][\$#].*) | (mysql>.*)') pattern = re.compile(r'([\[.*@.*\][\$#].* | mysql>.*])')
if log: if log:
filename = log.log_path filename = log.log_path
if os.path.isfile(filename): if os.path.isfile(filename):

View File

@ -154,7 +154,7 @@
// 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>'); tag.append('<p style="margin: 2px">'+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>');
} }

View File

@ -79,8 +79,8 @@
<a href="../user_edit/?id={{ user.id }}" class="btn btn-xs btn-info">缂栬緫</a> <a href="../user_edit/?id={{ user.id }}" class="btn btn-xs btn-info">缂栬緫</a>
<a href="../user_del/?id={{ user.id }}" class="btn btn-xs btn-danger {% if user.username == 'admin' %} disabled {% endif %}">鍒犻櫎</a> <a href="../user_del/?id={{ user.id }}" class="btn btn-xs btn-danger {% if user.username == 'admin' %} disabled {% endif %}">鍒犻櫎</a>
{% else %} {% else %}
<a href="../user_edit/?id={{ user.id }}" class="btn btn-xs btn-info {% if user.role == 'CU' %} disabled {% endif %}">缂栬緫</a> <a href="../user_edit/?id={{ user.id }}" class="btn btn-xs btn-info {% if user.role != 'CU' %} disabled {% endif %}">缂栬緫</a>
<a href="../user_del/?id={{ user.id }}" class="btn btn-xs btn-danger {% if user.role == 'CU' %} disabled {% endif %}">鍒犻櫎</a> <a href="../user_del/?id={{ user.id }}" class="btn btn-xs btn-danger {% if user.role != 'CU' %} disabled {% endif %}">鍒犻櫎</a>
{% endifequal %} {% endifequal %}
</td> </td>
</tr> </tr>