role推送基本完成

pull/26/head
ibuler 2015-11-30 23:04:02 +08:00
parent 7106e915ef
commit 4b36fc540d
4 changed files with 60 additions and 10 deletions

View File

@ -13,9 +13,9 @@ urlpatterns = patterns('jperm.views',
(r'^role/perm_role_detail/$', perm_role_detail),
(r'^role/perm_role_edit/$', perm_role_edit),
(r'^role/push/$', perm_role_push),
(r'^role/recycle/$', perm_role_recycle),
(r'^sudo/$', perm_sudo_list),
(r'^sudo/perm_sudo_add/$', perm_sudo_add),
(r'^sudo/perm_sudo_delete/$', perm_sudo_delete),
(r'^sudo/perm_sudo_edit/$', perm_sudo_edit),
)

View File

@ -319,6 +319,7 @@ def perm_role_detail(request):
if request.method == "GET":
role_id = request.GET.get("id")
role = get_object(PermRole, id=role_id)
role_info = get_role_info(role_id)
# 渲染数据
@ -574,3 +575,15 @@ def perm_sudo_delete(request):
return HttpResponse(u"不支持该操作")
@require_role('admin')
def perm_role_recycle(request):
role_id = request.GET.get('role_id')
asset_ids = request.GET.get('asset_id').split(',')
for asset_id in asset_ids:
asset = get_object(Asset, id=asset_id)
role = get_object(PermRole, id=role_id)
PermPush.objects.filter(asset=asset, role=role).delete()
return HttpResponse('删除成功')

View File

@ -1,7 +1,6 @@
{% extends 'base.html' %}
{% load mytags %}
{% block content %}
{% include 'nav_cat_bar.html' %}
<div class="wrapper wrapper-content animated fadeInRight">
@ -146,7 +145,7 @@
</div>
</div>
<div class="row">
<div class="col-sm-4">
<div class="col-sm-6">
<div class="ibox float-e-margins">
<div class="ibox-title">
<span class="label label-primary"><b>推送主机</b></span>
@ -172,17 +171,25 @@
<div>
<div class="text-left">
<table class="table table-striped" id="ugedit" >
<a class="btn btn-xs btn-danger del_muti"> 删除 </a>
<thead>
<tr>
<th class="text-center">
<input type="checkbox" id="check_all" onclick="checkAll()">
</th>
<th class="text-center">主机</th>
<th class="text-center">密钥</th>
<th class="text-center">密码</th>
<th class="text-center">结果</th>
<th class="text-center">操作</th>
</tr>
</thead>
<tbody>
{% for asset, info in pushed_asset.items %}
<tr class="gradeX">
<th class="text-center">
<input type="checkbox" name="checked" value="{{ asset.id }}">
</th>
<td class="text-center"> {{ asset.hostname }} </td>
<td class="text-center"> {{ info.key | yesno:"是,否,未知" }} </td>
<td class="text-center"> {{ info.password | yesno:"是,否,未知" }} </td>
@ -191,6 +198,7 @@
{% else %}
<td class="text-center" style="color: #ec4758;cursor: help" title="{{ info.result }}" >{{ info.success | yesno:"成功,失败,未知" }} </td>
{% endif %}
<td class="text-center" ><a class="fa fa-times del" href="/jperm/role/recycle/?role_id={{ role.id }}&asset_id={{ asset.id }}" style="color: #ec4758;"></a></td>
</tr>
{% endfor %}
</tbody>
@ -245,14 +253,43 @@
</div>
</div>
{% endblock %}
{% block self_footer_js %}
<script>
$(document).ready(function(){
$('#show').click(function(){
$('#last').css('display', 'none');
$('#all').css('display', 'block');
})
$('.del').click(function(){
var url = $(this).attr('href');
$.get(
url,
{},
function(data){
location.reload()
}
);
return false;
});
$('.del_muti').click(function(){
var check_array = [];
if (confirm("确定删除")) {
$(".gradeX input:checked").each(function() {
check_array.push($(this).attr("value"))
});
var url = '/jperm/role/recycle/?role_id={{ role.id }}&asset_id=' + check_array.join(',');
$.get(url,
{},
function(data){
location.reload()
}
)
}
return false;
});
})
</script>
{% endblock %}

View File

@ -99,7 +99,7 @@ function remove_role(role_id){
del_row.remove()
},
error: function (msg) {
console.log(msg)
console.log(msg);
alert("失败: " + msg)
}
});