diff --git a/jumpserver/views.py b/jumpserver/views.py index a99ec4f56..269053d35 100644 --- a/jumpserver/views.py +++ b/jumpserver/views.py @@ -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,17 +80,21 @@ def index_cu(request): login_types = {'L': 'LDAP', 'M': 'MAP'} username = request.user.username # TODO: need fix,liuzheng need Asset help - asset = get_group_user_perm(request.user) - print asset - assets = asset.get('asset') - # idc = [] - # for i in assets: - # idc.append(i.idc.id) - # idc_all = IDC.objects.filter(id__in=idc) - idc_all = [] + GUP = get_group_user_perm(request.user) + print GUP + assets = GUP.get('asset') + idcs = [] for i in assets: - idc_all.append(i.idc) - asset_group_all = asset.get('asset_group') + 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/views.py b/juser/views.py index e0a318433..dc02487a7 100644 --- a/juser/views.py +++ b/juser/views.py @@ -489,7 +489,10 @@ def down_key(request): 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': - print get_group_user_perm(request.user) + 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/juser/run_command.html b/templates/juser/run_command.html new file mode 100644 index 000000000..f075f9c90 --- /dev/null +++ b/templates/juser/run_command.html @@ -0,0 +1,138 @@ +{% extends 'base.html' %} + +{% load mytags %} +{% block content %} +{% include 'nav_cat_bar.html' %} + +
+ +{% endblock %} +{% block self_head_css_js %} + {% load staticfiles %} + + + + +{% endblock %} +{% block self_footer_js %} + +{% endblock %} \ No newline at end of file diff --git a/templates/upload.html b/templates/upload.html index 88e859a88..fb50a7cfa 100644 --- a/templates/upload.html +++ b/templates/upload.html @@ -73,6 +73,11 @@