From 01cf2d4e7be77758de516e1c8d0295047a7ef214 Mon Sep 17 00:00:00 2001 From: yumaojun <719118794@qq.com> Date: Tue, 5 Jan 2016 17:22:25 +0800 Subject: [PATCH] =?UTF-8?q?=E5=88=A0=E9=99=A4role=E6=97=B6=E6=8F=90?= =?UTF-8?q?=E9=86=92=E9=82=A3=E4=BA=9B=20=E4=B8=BB=E6=9C=BA=E4=B8=8A?= =?UTF-8?q?=E7=9A=84=E7=B3=BB=E7=BB=9F=E7=94=A8=E6=88=B7=E4=BC=9A=E8=A2=AB?= =?UTF-8?q?=E5=88=A0=E9=99=A4=EF=BC=8C=20=EF=BC=88=E9=9C=80=E6=B1=82?= =?UTF-8?q?=EF=BC=9Ahttp://bbs.jumpserver.org/read/325.html=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- jperm/views.py | 27 +++++++++++++-- templates/jperm/perm_role_list.html | 53 ++++++++++++++++++++--------- 2 files changed, 62 insertions(+), 18 deletions(-) diff --git a/jperm/views.py b/jperm/views.py index 680058508..0e45319f4 100644 --- a/jperm/views.py +++ b/jperm/views.py @@ -319,14 +319,37 @@ def perm_role_delete(request): """ delete role page """ + if request.method == "GET": + try: + # 获取参数删除的role对象 + role_id = request.GET.get("id") + role = get_object(PermRole, id=role_id) + if not role: + logger.warning(u"Delete Role: role_id %s not exist" % role_id) + raise ServerError(u"role_id %s 无数据记录" % role_id) + # 删除推送到主机上的role + filter_type = request.GET.get("filter_type") + print filter_type + if filter_type: + if filter_type == "recycle_assets": + recycle_assets = [push.asset for push in role.perm_push.all() if push.success] + print recycle_assets + recycle_assets_ip = ','.join([asset.ip for asset in recycle_assets]) + return HttpResponse(recycle_assets_ip) + else: + return HttpResponse("no such filter_type: %s" % filter_type) + else: + return HttpResponse("filter_type: ?") + except ServerError, e: + return HttpResponse(e) if request.method == "POST": try: # 获取参数删除的role对象 role_id = request.POST.get("id") role = get_object(PermRole, id=role_id) if not role: - logger.warning(u"Delete Role: %s not exist" % role.name) - raise ServerError(u"%s 无数据记录" % role.name) + logger.warning(u"Delete Role: role_id %s not exist" % role_id) + raise ServerError(u"role_id %s 无数据记录" % role_id) role_key = role.key_path # 删除推送到主机上的role recycle_assets = [push.asset for push in role.perm_push.all() if push.success] diff --git a/templates/jperm/perm_role_list.html b/templates/jperm/perm_role_list.html index 3e998de5a..b371880ac 100644 --- a/templates/jperm/perm_role_list.html +++ b/templates/jperm/perm_role_list.html @@ -84,22 +84,43 @@