fix some bug

pull/26/head
ibuler 9 years ago
parent 483ca9677c
commit 4c50551249

@ -109,8 +109,8 @@ def get_role_name(request):
asset = get_object(Asset, id=asset_id)
if asset:
role = user_have_perm(request.user, asset=asset)
return HttpResponse(','.join(list(role)))
return HttpResponse('dev,sa')
return HttpResponse(','.join([i.name for i in role]))
return HttpResponse('error')
@require_role()

@ -57,15 +57,13 @@ def require_auth(func):
uid = session.get_decoded().get('_auth_user_id')
user = User.objects.filter(id=uid)
asset_id = int(request.get_argument('id', 9999))
print asset_id
asset = Asset.objects.filter(id=asset_id)
if asset:
asset = asset[0]
request.asset = asset
role = user_have_perm(user, asset)
request.role = role
else:
role = ''
request.close()
if user:
user = user[0]
@ -247,6 +245,7 @@ class WebTerminalHandler(tornado.websocket.WebSocketHandler):
if role.name == role_name:
login_role = role
break
print login_role
if not login_role:
print "no role"
self.close()

@ -170,8 +170,8 @@
}
});
$('.conn').click(function(evt){
var url='/jlog/get_role_name/?id' + $(this).attr('value');
$('.conn').click(function(){
var url='/jlog/get_role_name/?id=' + $(this).attr('value');
var href = $(this).attr('href');
var new_url = '/jlog/web_terminal/?id=' + $(this).attr('value') + '&role=';
$.ajax({
@ -179,10 +179,11 @@
url: url,
data: {},
success: function(data){
console.log(data);
var dataArray = data.split(',');
if (dataArray.length == 1){
if (dataArray.length == 1 && data != 'error'){
window.open(new_url + data, '播放', 'height=400, width=600, top=89px, left=99px,toolbar=no,menubar=no,scrollbars=auto,resizeable=no,location=no,status=no');
} else if (dataArray.length == 0){
} else if (dataArray.length == '1' && data == 'error'){
layer.alert('没有授权角色')
} else {
aUrl = '';
@ -195,7 +196,6 @@
closeBtn: 0
})
}
}
});
return false
@ -204,7 +204,7 @@
function windowOpen(aTab){
var new_url = aTab.href;
window.open(new_url, '播放', 'height=400, width=600, top=89px, left=99px,toolbar=no,menubar=no,scrollbars=auto,resizeable=no,location=no,status=no');
window.open(new_url, '', 'height=400, width=600, top=89px, left=99px,toolbar=no,menubar=no,scrollbars=auto,resizeable=no,location=no,status=no');
return false
}

Loading…
Cancel
Save