mirror of https://github.com/jumpserver/jumpserver
授权编辑和查看修改完毕
parent
c09d1d25b2
commit
c1686d52e9
|
@ -10,4 +10,5 @@ urlpatterns = patterns('jperm.views',
|
|||
(r'^perm_list/$', 'perm_list'),
|
||||
(r'^perm_detail/$', 'perm_detail'),
|
||||
(r'^perm_del/$', 'perm_del'),
|
||||
(r'^perm_asset_detail/$', 'perm_asset_detail'),
|
||||
)
|
||||
|
|
|
@ -25,6 +25,23 @@ def perm_group_update(user_group_name='', user_group_id='', asset_groups_name=''
|
|||
Perm(user_group=user_group, asset_group=asset_group).save()
|
||||
|
||||
|
||||
def perm_user_asset(user_id):
|
||||
user = User.objects.get(id=user_id)
|
||||
user_groups = user.user_group.all()
|
||||
perms = []
|
||||
assets = []
|
||||
for user_group in user_groups:
|
||||
perm = user_group.perm_set.all()
|
||||
perms.extend(perm)
|
||||
|
||||
asset_groups = [perm.asset_group for perm in perms]
|
||||
|
||||
for asset_group in asset_groups:
|
||||
assets.extend(list(asset_group.asset_set.all()))
|
||||
|
||||
return list(set(assets))
|
||||
|
||||
|
||||
def perm_list(request):
|
||||
header_title, path1, path2 = u'涓绘満鎺堟潈 | Perm Host Detail.', u'jperm', u'perm_list'
|
||||
groups = contact_list = UserGroup.objects.all().order_by('type')
|
||||
|
@ -75,6 +92,12 @@ def perm_del(request):
|
|||
return HttpResponseRedirect('/jperm/perm_list/')
|
||||
|
||||
|
||||
def perm_asset_detail(request):
|
||||
user_id = request.GET.get('id')
|
||||
user = User.objects.get(id=user_id)
|
||||
assets = perm_user_asset(user_id)
|
||||
return render_to_response('jperm/perm_asset_detail.html', locals())
|
||||
|
||||
|
||||
# def perm_user_host(username, ips):
|
||||
# user = User.objects.get(username=username)
|
||||
|
|
|
@ -4,6 +4,7 @@ import time
|
|||
from django import template
|
||||
from django.db.models import Q
|
||||
from juser.models import User, UserGroup
|
||||
from jperm.views import perm_user_asset
|
||||
|
||||
register = template.Library()
|
||||
|
||||
|
@ -73,3 +74,7 @@ def group_type_to_str(type_name):
|
|||
'A': '鎺堟潈缁',
|
||||
}
|
||||
return group_types.get(type_name)
|
||||
|
||||
@register.filter(name='perm_asset_count')
|
||||
def perm_asset_count(user_id):
|
||||
return len(perm_user_asset(user_id))
|
||||
|
|
|
@ -0,0 +1,41 @@
|
|||
{% load mytags %}
|
||||
<html>
|
||||
<head>
|
||||
{% include 'link_css.html' %}
|
||||
|
||||
<style type="text/css">
|
||||
body
|
||||
{
|
||||
background: #FFFFFF;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div class="row">
|
||||
<div class="contact-box">
|
||||
<h2 class="text-center">{{ user.name }} 鎺堟潈璇︽儏</h2>
|
||||
<div class="ibox-content">
|
||||
|
||||
<table class="table table-striped table-bordered table-hover " id="editable" >
|
||||
<thead>
|
||||
<tr>
|
||||
<th class="text-center">涓绘満</th>
|
||||
<th class="text-center">绔彛</th>
|
||||
<th class="text-center">鐧诲綍鏂瑰紡</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% for asset in assets %}
|
||||
<tr class="gradeX">
|
||||
<td class="text-center">{{ asset.ip }}</td>
|
||||
<td class="text-center">{{ asset.port }}</td>
|
||||
<td class="text-center">{{ asset.login_type }}</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
|
@ -113,19 +113,22 @@
|
|||
<table class="table table-striped table-bordered table-hover " id="editable" >
|
||||
<thead>
|
||||
<tr>
|
||||
<th class="text-center">缁勫悕</th>
|
||||
<th class="text-center">澶囨敞</th>
|
||||
<th class="text-center">鐢ㄦ埛</th>
|
||||
<th class="text-center">瑙掕壊</th>
|
||||
<th class="text-center">灞炵粍</th>
|
||||
<th class="text-center">涓绘満鏁伴噺</th>
|
||||
<th class="text-center">鎿嶄綔</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% for group in contacts2.object_list %}
|
||||
{% for user in contacts2.object_list %}
|
||||
<tr class="gradeX">
|
||||
<td class="text-center"> {{ group.name }} </td>
|
||||
<td class="text-center"> {{ group.comment }} </td>
|
||||
<td class="text-center"> {{ user.name }} </td>
|
||||
<td class="text-center"> {{ user.id | get_role }} </td>
|
||||
<td class="text-center"> {{ user.username | groups_str }} </td>
|
||||
<td class="text-center"> {{ user.id | perm_asset_count }} </td>
|
||||
<td class="text-center">
|
||||
<a href="../perm_group_detail/?id={{ user.id }}" class="iframe btn btn-xs btn-primary">璇︽儏</a>
|
||||
<a href="../perm_group_edit/?id={{ user.id }}" class="btn btn-xs btn-info">缂栬緫</a>
|
||||
<a href="../perm_asset_detail/?id={{ user.id }}" class="iframe btn btn-xs btn-primary">璇︽儏</a>
|
||||
</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
|
|
Loading鈥
Reference in New Issue