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
61eadf68
Commit
61eadf68
authored
Nov 02, 2016
by
ibuler
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Modify asset detail
parent
3448f3eb
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
77 additions
and
3 deletions
+77
-3
forms.py
apps/assets/forms.py
+1
-0
asset_create.html
apps/assets/templates/assets/asset_create.html
+1
-0
asset_detail.html
apps/assets/templates/assets/asset_detail.html
+52
-1
asset_update.html
apps/assets/templates/assets/asset_update.html
+1
-0
views.py
apps/assets/views.py
+5
-1
forms.py
apps/perms/forms.py
+10
-0
hands.py
apps/perms/hands.py
+7
-1
No files found.
apps/assets/forms.py
View file @
61eadf68
...
...
@@ -58,6 +58,7 @@ class AssetCreateForm(forms.ModelForm):
help_texts
=
{
'hostname'
:
'* required'
,
'ip'
:
'* required'
,
'system_users'
:
_
(
'System user will be granted for user to login assets (using ansible create automatic)'
),
'admin_user'
:
_
(
'Admin user should be exist on asset already, And have sudo ALL permission'
),
'tags'
:
'最多5个标签,单个标签最长8个汉字,按回车确认'
}
...
...
apps/assets/templates/assets/asset_create.html
View file @
61eadf68
...
...
@@ -20,6 +20,7 @@
<div
class=
"hr-line-dashed"
></div>
<h3>
{% trans 'Asset user' %}
</h3>
{{ form.admin_user|bootstrap_horizontal }}
{{ form.system_users|bootstrap_horizontal }}
<div
class=
"hr-line-dashed"
></div>
<h3>
{% trans 'Other' %}
</h3>
...
...
apps/assets/templates/assets/asset_detail.html
View file @
61eadf68
...
...
@@ -54,6 +54,14 @@
<td>
{% trans 'IP' %}:
</td>
<td><b>
{{ asset.ip }}
</b></td>
</tr>
<tr>
<td>
{% trans 'Admin user' %}:
</td>
{% if asset.admin_user %}
<td><b>
{{ asset.admin_user.name }}
</b></td>
{% else %}
<td><b>
None
</b></td>
{% endbif %}
</tr>
<tr>
<td>
{% trans 'Other IP' %}:
</td>
<td><b>
{{ asset.other_ip }}
</b></td>
...
...
@@ -173,7 +181,15 @@
</span>
</td>
</tr>
</tbody>
<tr>
<td>
{% trans 'Repush system users' %}:
</td>
<td>
<span
class=
"pull-right"
>
<button
type=
"button"
class=
"btn btn-primary btn-xs"
id=
"btn_reset_pk"
style=
"width: 54px;"
>
{% trans 'Push' %}
</button>
</span>
</td>
</tr>
</tbody>
</table>
</div>
...
...
@@ -215,6 +231,41 @@
</table>
</div>
</div>
<div
class=
"panel panel-warning"
>
<div
class=
"panel-heading"
>
<i
class=
"fa fa-info-circle"
></i>
{% trans 'Asset groups' %}
</div>
<div
class=
"panel-body"
>
<table
class=
"table group_edit"
>
<tbody>
<form>
<tr
class=
"no-borders-tr"
>
<td
colspan=
"2"
>
<select
data-placeholder=
"{% trans 'Select system user' %}"
class=
"select2"
style=
"width: 100%"
multiple=
""
tabindex=
"4"
>
{% for system_user in system_users_remain %}
<option
value=
"{{ system_user.id }}"
>
{{ system_user.name }}
</option>
{% endfor %}
</select>
</td>
</tr>
<tr
class=
"no-borders-tr"
>
<td
colspan=
"2"
>
<button
type=
"button"
class=
"btn btn-warning btn-sm"
>
{% trans 'Associate' %}
</button>
</td>
</tr>
</form>
{% for system_user in system_users %}
<tr>
<td
><b>
{{ system_user.name }}
</b></td>
<td>
<button
class=
"btn btn-danger btn-xs"
type=
"button"
style=
"float: right;"
><i
class=
"fa fa-minus"
></i></button>
</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
</div>
</div>
</div>
</div>
...
...
apps/assets/templates/assets/asset_update.html
View file @
61eadf68
...
...
@@ -25,6 +25,7 @@
<div
class=
"hr-line-dashed"
></div>
<h3>
{% trans 'Asset user' %}
</h3>
{{ form.admin_user|bootstrap_horizontal }}
{{ form.system_users|bootstrap_horizontal }}
<div
class=
"hr-line-dashed"
></div>
<h3>
{% trans 'Hardware' %}
</h3>
...
...
apps/assets/views.py
View file @
61eadf68
...
...
@@ -135,12 +135,16 @@ class AssetDetailView(DetailView):
def
get_context_data
(
self
,
**
kwargs
):
asset_groups
=
self
.
object
.
groups
.
all
()
system_users
=
self
.
object
.
system_users
.
all
()
context
=
{
'app'
:
'Assets'
,
'action'
:
'Asset detail'
,
'asset_groups_remain'
:
[
asset_group
for
asset_group
in
AssetGroup
.
objects
.
all
()
if
asset_group
not
in
asset_groups
],
if
asset_group
not
in
asset_groups
],
'asset_groups'
:
asset_groups
,
'system_users_remain'
:
[
system_user
for
system_user
in
SystemUser
.
objects
.
all
()
if
system_user
not
in
system_users
],
'system_users'
:
system_users
,
}
kwargs
.
update
(
context
)
return
super
(
AssetDetailView
,
self
)
.
get_context_data
(
**
kwargs
)
...
...
apps/perms/forms.py
View file @
61eadf68
...
...
@@ -6,9 +6,18 @@ from django.utils.translation import ugettext_lazy as _
# from .hands import User, UserGroup, Asset, AssetGroup, SystemUser
from
.models
import
AssetPermission
from
.hands
import
associate_system_users_with_assets
class
AssetPermissionForm
(
forms
.
ModelForm
):
def
save
(
self
,
commit
=
True
):
instance
=
super
(
AssetPermissionForm
,
self
)
.
save
(
commit
=
commit
)
assets
=
instance
.
assets
.
all
()
asset_groups
=
instance
.
asset_groups
.
all
()
system_users
=
instance
.
system_users
.
all
()
associate_system_users_with_assets
(
system_users
,
assets
,
asset_groups
)
return
instance
class
Meta
:
model
=
AssetPermission
...
...
@@ -34,3 +43,4 @@ class AssetPermissionForm(forms.ModelForm):
'asset_groups'
:
'* Asset or Asset group at least one required'
,
'system_users'
:
'* required'
,
}
apps/perms/hands.py
View file @
61eadf68
...
...
@@ -2,7 +2,13 @@
#
from
users.utils
import
AdminUserRequiredMixin
# from users.backends import IsValdiUser
from
users.models
import
User
,
UserGroup
from
assets.models
import
Asset
,
AssetGroup
,
SystemUser
def
associate_system_users_with_assets
(
system_users
,
assets
,
asset_groups
):
for
asset
in
assets
:
asset
.
system_users
.
add
(
*
tuple
(
system_users
))
for
asset_group
in
asset_groups
:
asset_group
.
system_users
.
add
(
*
tuple
(
system_users
))
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