diff --git a/jperm/urls.py b/jperm/urls.py index 53ebbc758..30a4fae1f 100644 --- a/jperm/urls.py +++ b/jperm/urls.py @@ -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'), ) diff --git a/jperm/views.py b/jperm/views.py index 0f0226a08..f80840543 100644 --- a/jperm/views.py +++ b/jperm/views.py @@ -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): diff --git a/templates/jperm/perm_user_detail.html b/templates/jperm/perm_detail.html similarity index 54% rename from templates/jperm/perm_user_detail.html rename to templates/jperm/perm_detail.html index 09116581d..8f5f7521a 100644 --- a/templates/jperm/perm_user_detail.html +++ b/templates/jperm/perm_detail.html @@ -14,29 +14,23 @@
ID | -IP | 主机组 | -IDC | +主机数量 | ||
---|---|---|---|---|---|---|
{{ asset.id }} | -{{ asset.ip }} | -- {% for group in asset.bis_group.all %} - {{ group }} - {% endfor %} - | -{{ asset.idc.name }} | +{{ asset_group.id }} | +{{ asset_group.name }} | +{{ asset_group.asset_set.count }} | {{ group.id|member_count }} | {{ group.id|perm_count }} | - 详情 + 详情 编辑 - 删除 + 删除 | {% endfor %}