From c09d1d25b256d07f6bc51b711b8b8577a21ab708 Mon Sep 17 00:00:00 2001 From: guanghongwei Date: Fri, 30 Jan 2015 14:54:45 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8E=88=E6=9D=83=E7=BC=96=E8=BE=91=E4=BF=AE?= =?UTF-8?q?=E6=94=B9ok?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- jperm/urls.py | 3 ++- jperm/views.py | 17 ++++++++++++++++- ...{perm_user_detail.html => perm_detail.html} | 18 ++++++------------ templates/jperm/perm_list.html | 4 ++-- 4 files changed, 26 insertions(+), 16 deletions(-) rename templates/jperm/{perm_user_detail.html => perm_detail.html} (54%) 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 @@
-

{{ user.name }} 授权详情

+

{{ group.name }} 授权详情

- - + - {% for asset in host_permed %} + {% for asset_group in asset_groups %} - - - - + + + {% endfor %} diff --git a/templates/jperm/perm_list.html b/templates/jperm/perm_list.html index fa5bc90e4..6e56381d7 100644 --- a/templates/jperm/perm_list.html +++ b/templates/jperm/perm_list.html @@ -61,9 +61,9 @@ {% endfor %}
IDIP 主机组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 }} - 详情 + 详情 编辑 - 删除 + 删除