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) asset = get_object(Asset, id=asset_id)
if asset: if asset:
role = user_have_perm(request.user, asset=asset) role = user_have_perm(request.user, asset=asset)
return HttpResponse(','.join(list(role))) return HttpResponse(','.join([i.name for i in role]))
return HttpResponse('dev,sa') return HttpResponse('error')
@require_role() @require_role()

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

@ -170,8 +170,8 @@
} }
}); });
$('.conn').click(function(evt){ $('.conn').click(function(){
var url='/jlog/get_role_name/?id' + $(this).attr('value'); var url='/jlog/get_role_name/?id=' + $(this).attr('value');
var href = $(this).attr('href'); var href = $(this).attr('href');
var new_url = '/jlog/web_terminal/?id=' + $(this).attr('value') + '&role='; var new_url = '/jlog/web_terminal/?id=' + $(this).attr('value') + '&role=';
$.ajax({ $.ajax({
@ -179,10 +179,11 @@
url: url, url: url,
data: {}, data: {},
success: function(data){ success: function(data){
console.log(data);
var dataArray = data.split(','); 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'); 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('没有授权角色') layer.alert('没有授权角色')
} else { } else {
aUrl = ''; aUrl = '';
@ -195,7 +196,6 @@
closeBtn: 0 closeBtn: 0
}) })
} }
} }
}); });
return false return false
@ -204,7 +204,7 @@
function windowOpen(aTab){ function windowOpen(aTab){
var new_url = aTab.href; 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 return false
} }

Loading…
Cancel
Save