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
a8ce9e99
Commit
a8ce9e99
authored
Jan 21, 2015
by
ibuler
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
添加授权
parent
8bc7485c
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
20 additions
and
3 deletions
+20
-3
views.py
jpermission/views.py
+14
-0
perm_add.html
templates/jperm/perm_add.html
+6
-3
No files found.
jpermission/views.py
View file @
a8ce9e99
...
...
@@ -4,6 +4,7 @@ from django.shortcuts import render_to_response
from
django.http
import
HttpResponseRedirect
from
juser.models
import
User
from
jasset.models
import
Asset
from
jpermission.models
import
Permission
def
perm_user_list
(
request
):
...
...
@@ -14,6 +15,7 @@ def perm_user_list(request):
def
perm_add
(
request
):
header_title
,
path1
,
path2
=
u'添加授权 | Add User perm.'
,
u'授权管理'
,
u'添加授权'
if
request
.
method
==
'GET'
:
username
=
request
.
GET
.
get
(
'username'
,
None
)
if
not
username
:
return
HttpResponseRedirect
(
'/'
)
...
...
@@ -26,4 +28,15 @@ def perm_add(request):
hosts_all
=
Asset
.
objects
.
all
()
hosts
=
list
(
set
(
hosts_all
)
-
set
(
permed_hosts
))
else
:
username
=
request
.
POST
.
get
(
'username'
,
None
)
host_ips
=
request
.
POST
.
getlist
(
'host_ips'
,
None
)
user
=
User
.
objects
.
get
(
username
=
username
)
for
ip
in
host_ips
:
asset
=
Asset
.
objects
.
get
(
ip
=
ip
)
perm
=
Permission
(
user
=
user
,
asset
=
asset
)
perm
.
save
()
msg
=
u'添加成功'
return
render_to_response
(
'jperm/perm_add.html'
,
locals
())
\ No newline at end of file
templates/jperm/perm_add.html
View file @
a8ce9e99
...
...
@@ -37,14 +37,17 @@
{% endif %}
<div
class=
"form-group"
>
<div
class=
"col-sm-8"
>
<select
id=
"host_ips"
name=
"host_ips"
multiple
>
<input
name=
"username"
value=
"{{ user.username }}"
hidden=
"hidden"
>
</div>
</div>
<div
class=
"form-group"
>
<div
class=
"col-sm-8"
>
<select
id=
"host_ips"
name=
"host_ips"
multiple
style=
"width: 100%"
>
{% for host in hosts %}
<option
value=
"{{ host.id }}"
>
{{ host.ip }}
</option>
{% endfor %}
</select>
{% for host in hosts %}
{% endfor %}
</div>
</div>
...
...
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