From 53c3767b1ba3d1bb7e59322b7f987a4499fe8178 Mon Sep 17 00:00:00 2001 From: ibuler Date: Wed, 21 Jan 2015 23:44:14 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E6=8E=88=E6=9D=83=E9=A1=B5?= =?UTF-8?q?=E9=9D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- jpermission/views.py | 19 ++++++ templates/jperm/perm_add.html | 102 +++------------------------- templates/jperm/perm_user_list.html | 2 +- 3 files changed, 28 insertions(+), 95 deletions(-) diff --git a/jpermission/views.py b/jpermission/views.py index d850f3d8d..c3d5e59fc 100644 --- a/jpermission/views.py +++ b/jpermission/views.py @@ -1,10 +1,29 @@ # coding: utf-8 from django.shortcuts import render_to_response +from django.http import HttpResponseRedirect from juser.models import User +from jasset.models import Asset def perm_user_list(request): header_title, path1, path2 = u'查看授权用户 | Perm User Detail.', u'授权管理', u'用户详情' users = User.objects.all() return render_to_response('jperm/perm_user_list.html', locals(),) + + +def perm_add(request): + header_title, path1, path2 = u'添加授权 | Add User perm.', u'授权管理', u'添加授权' + username = request.GET.get('username', None) + if not username: + return HttpResponseRedirect('/') + + user = User.objects.get(username=username) + permed_hosts = [] + for perm in user.permission_set.all(): + permed_hosts.append(perm.asset) + + hosts_all = Asset.objects.all() + hosts = list(set(hosts_all) - set(permed_hosts)) + + return render_to_response('jperm/perm_add.html', locals()) \ No newline at end of file diff --git a/templates/jperm/perm_add.html b/templates/jperm/perm_add.html index 7506b04ad..dcfde9f25 100644 --- a/templates/jperm/perm_add.html +++ b/templates/jperm/perm_add.html @@ -8,7 +8,7 @@