授权编辑修改ok

pull/6/head
guanghongwei 2015-01-30 14:54:45 +08:00
parent d25a3ce17c
commit c09d1d25b2
4 changed files with 26 additions and 16 deletions

View File

@ -7,6 +7,7 @@ urlpatterns = patterns('jperm.views',
# url(r'^blog/', include('blog.urls')),
(r'^perm_edit/$', 'perm_edit'),
(r'^perm_user_show/$', 'perm_user_show'),
(r'^perm_list/$', 'perm_list'),
(r'^perm_detail/$', 'perm_detail'),
(r'^perm_del/$', 'perm_del'),
)

View File

@ -61,6 +61,21 @@ def perm_edit(request):
return HttpResponseRedirect('/jperm/perm_list/')
def perm_detail(request):
user_group_id = request.GET.get('id')
user_group = UserGroup.objects.get(id=user_group_id)
asset_groups = [perm.asset_group for perm in user_group.perm_set.all()]
return render_to_response('jperm/perm_detail.html', locals())
def perm_del(request):
user_group_id = request.GET.get('id')
user_group = UserGroup.objects.get(id=user_group_id)
Perm.objects.filter(user_group=user_group).delete()
return HttpResponseRedirect('/jperm/perm_list/')
# def perm_user_host(username, ips):
# user = User.objects.get(username=username)
# user.perm_set.all().delete()
@ -96,7 +111,7 @@ def perm_edit(request):
# for perm in user.perm_set.all():
# host_permed.append(perm.asset)
#
# return render_to_response('jperm/perm_user_detail.html', locals())
# return render_to_response('jperm/perm_detail.html', locals())
#
#
# def perm_group_edit(request):

View File

@ -14,29 +14,23 @@
<body>
<div class="row">
<div class="contact-box">
<h2 class="text-center">{{ user.name }} 鎺堟潈璇︽儏</h2>
<h2 class="text-center">{{ group.name }} 鎺堟潈璇︽儏</h2>
<div class="ibox-content">
<table class="table table-striped table-bordered table-hover " id="editable" >
<thead>
<tr>
<th class="text-center">ID</th>
<th class="text-center">IP</th>
<th class="text-center">涓绘満缁</th>
<th class="text-center">IDC</th>
<th class="text-center">涓绘満鏁伴噺</th>
</tr>
</thead>
<tbody>
{% for asset in host_permed %}
{% for asset_group in asset_groups %}
<tr class="gradeX">
<td class="text-center">{{ asset.id }}</td>
<td class="text-center">{{ asset.ip }}</td>
<td class="text-center">
{% for group in asset.bis_group.all %}
{{ group }}
{% endfor %}
</td>
<td class="text-center">{{ asset.idc.name }}</td>
<td class="text-center">{{ asset_group.id }}</td>
<td class="text-center">{{ asset_group.name }}</td>
<td class="text-center">{{ asset_group.asset_set.count }}</td>
</tr>
{% endfor %}

View File

@ -61,9 +61,9 @@
<td class="text-center"> {{ group.id|member_count }} </td>
<td class="text-center"> {{ group.id|perm_count }} </td>
<td class="text-center">
<a href="../perm_user_detail/?id={{ group.id }}" class="iframe btn btn-xs btn-primary">璇︽儏</a>
<a href="../perm_detail/?id={{ group.id }}" class="iframe btn btn-xs btn-primary">璇︽儏</a>
<a href="../perm_edit/?id={{ group.id }}" class="btn btn-xs btn-info">缂栬緫</a>
<a href="../perm_user_edit/?id={{ usgrouper.id }}" class="btn btn-xs btn-danger">鍒犻櫎</a>
<a href="../perm_del/?id={{ group.id }}" class="btn btn-xs btn-danger">鍒犻櫎</a>
</td>
</tr>
{% endfor %}