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
d9b4f550
Commit
d9b4f550
authored
9 years ago
by
ibuler
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'dev'
parents
e9212d5c
01511c0d
No related merge requests found
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
62 additions
and
18 deletions
+62
-18
views.py
jperm/views.py
+25
-2
perm_role_list.html
templates/jperm/perm_role_list.html
+37
-16
No files found.
jperm/views.py
View file @
d9b4f550
...
...
@@ -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
]
...
...
This diff is collapsed.
Click to expand it.
templates/jperm/perm_role_list.html
View file @
d9b4f550
...
...
@@ -84,22 +84,43 @@
<script>
function
remove_role
(
role_id
){
if
(
confirm
(
"对应资产上已推送的系统用户会被删除,包括其家目录,请谨慎操作!"
))
{
$
.
ajax
({
type
:
"POST"
,
url
:
"{% url 'role_del' %}"
,
data
:
"id="
+
role_id
,
success
:
function
(
msg
){
alert
(
"成功: "
+
msg
);
var
del_row
=
$
(
'tbody#edittbody>tr#'
+
role_id
);
del_row
.
remove
()
},
error
:
function
(
msg
)
{
console
.
log
(
msg
);
alert
(
"失败: "
+
msg
.
responseText
)
}
});
}
$
.
ajax
({
type
:
"GET"
,
url
:
"{% url 'role_del' %}"
,
data
:
{
id
:
role_id
,
filter_type
:
'recycle_assets'
},
success
:
function
(
data
)
{
console
.
log
(
data
)
if
(
data
)
{
msg
=
data
+
"的系统用户会被删除,包括其家目录,请谨慎操作!"
}
else
{
msg
=
"该角色无已推送的系统用户, 可以安全删除"
}
if
(
confirm
(
msg
))
{
$
.
ajax
({
type
:
"POST"
,
url
:
"{% url 'role_del' %}"
,
data
:
"id="
+
role_id
,
success
:
function
(
msg
){
alert
(
"成功: "
+
msg
);
var
del_row
=
$
(
'tbody#edittbody>tr#'
+
role_id
);
del_row
.
remove
()
},
error
:
function
(
msg
)
{
console
.
log
(
msg
);
alert
(
"失败: "
+
msg
.
responseText
)
}
});
}
},
error
:
function
(
error
)
{
alert
(
error
)
},
});
}
</script>
...
...
This diff is collapsed.
Click to expand it.
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