Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
J
jumpserver
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
ops
jumpserver
Commits
4b36fc54
Commit
4b36fc54
authored
Nov 30, 2015
by
ibuler
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
role推送基本完成
parent
7106e915
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
61 additions
and
10 deletions
+61
-10
urls.py
jperm/urls.py
+1
-1
views.py
jperm/views.py
+13
-0
perm_role_detail.html
templates/jperm/perm_role_detail.html
+46
-8
perm_role_list.html
templates/jperm/perm_role_list.html
+1
-1
No files found.
jperm/urls.py
View file @
4b36fc54
...
...
@@ -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
),
)
jperm/views.py
View file @
4b36fc54
...
...
@@ -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
(
'删除成功'
)
templates/jperm/perm_role_detail.html
View file @
4b36fc54
{% 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'
);
})
})
</script>
$
(
'.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 %}
\ No newline at end of file
templates/jperm/perm_role_list.html
View file @
4b36fc54
...
...
@@ -99,7 +99,7 @@ function remove_role(role_id){
del_row
.
remove
()
},
error
:
function
(
msg
)
{
console
.
log
(
msg
)
console
.
log
(
msg
)
;
alert
(
"失败: "
+
msg
)
}
});
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment