diff --git a/jumpserver/views.py b/jumpserver/views.py index 87cdf0126..4563a9fd4 100644 --- a/jumpserver/views.py +++ b/jumpserver/views.py @@ -16,7 +16,7 @@ from jumpserver.models import Setting from django.contrib.auth import authenticate, login, logout from django.contrib.auth.decorators import login_required from jlog.models import Log - +from jperm.perm_api import get_group_user_perm def getDaysByNum(num): """ @@ -72,7 +72,7 @@ def get_count_by_date(date_li, item): return len(set(data_count_tmp)) - +from jasset.models import Asset, IDC @require_role(role='user') def index_cu(request): # user_id = request.user.id @@ -80,6 +80,21 @@ def index_cu(request): login_types = {'L': 'LDAP', 'M': 'MAP'} username = request.user.username # TODO: need fix,liuzheng need Asset help + GUP = get_group_user_perm(request.user) + print GUP + assets = GUP.get('asset') + idcs = [] + for i in assets: + if i.idc_id: + idcs.append(i.idc_id) + idc_all = IDC.objects.filter(id__in=idcs) + for i in idc_all: + print i.name + # idc_all = [] + # for i in assets: + # idc_all.append(i.idc) + # print i.idc.name + asset_group_all = GUP.get('asset_group') # posts = Asset.object.all() # host_count = len(posts) # diff --git a/juser/urls.py b/juser/urls.py index 9764c01ce..bfd3a6270 100644 --- a/juser/urls.py +++ b/juser/urls.py @@ -28,4 +28,6 @@ urlpatterns = patterns('juser.views', (r'^change_role/$', 'chg_role'), (r'^regen_ssh_key/$', 'regen_ssh_key'), (r'^down_key/$', 'down_key'), + + (r'runcommand/$', 'RunCommand'), ) diff --git a/juser/views.py b/juser/views.py index 84f39954b..dc02487a7 100644 --- a/juser/views.py +++ b/juser/views.py @@ -12,7 +12,7 @@ from juser.user_api import * MAIL_FROM = EMAIL_HOST_USER - +@login_required(login_url='/login') def chg_role(request): role = {'SU': 2, 'GA': 1, 'CU': 0} if request.session['role_id'] > 0: @@ -238,10 +238,10 @@ def user_detail(request): # user, dept = get_session_user_dept(request) # if not validate(request, user=[user_id]): # return HttpResponseRedirect('/') - # if not user_id: - # return HttpResponseRedirect('/juser/user_list/') - - # user = get_object(User, id=user_id) + user_id = request.GET.get('id', '') + if not user_id: + return HttpResponseRedirect('/juser/user_list/') + user = User.objects.get(id=user_id) # if user: # pass # asset_group_permed = user.get_asset_group() @@ -487,4 +487,12 @@ def down_key(request): response['Content-Disposition'] = 'attachment; filename=%s' % os.path.basename(private_key_file) return response - return HttpResponse('No Key File. Contact Admin.') \ No newline at end of file + return HttpResponse('No Key File. Contact Admin.') +from jperm.perm_api import get_group_user_perm +@require_role(role='user') +def RunCommand(request): + if request.method == 'GET': + GUP = get_group_user_perm(request.user) + print GUP + assets = GUP.get('asset') + return render_to_response('juser/run_command.html', locals(), context_instance=RequestContext(request)) \ No newline at end of file diff --git a/templates/index_cu.html b/templates/index_cu.html index 3edb68a75..bfc8ef030 100644 --- a/templates/index_cu.html +++ b/templates/index_cu.html @@ -53,18 +53,147 @@
{{ host.ip }} | +