Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
gjl2004yn
jumpserver
提交
61eadf68
J
jumpserver
项目概览
gjl2004yn
/
jumpserver
与 Fork 源项目一致
从无法访问的项目Fork
通知
2
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
J
jumpserver
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
61eadf68
编写于
11月 03, 2016
作者:
baltery
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Modify asset detail
上级
3448f3eb
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
77 addition
and
3 deletion
+77
-3
apps/assets/forms.py
apps/assets/forms.py
+1
-0
apps/assets/templates/assets/asset_create.html
apps/assets/templates/assets/asset_create.html
+1
-0
apps/assets/templates/assets/asset_detail.html
apps/assets/templates/assets/asset_detail.html
+52
-1
apps/assets/templates/assets/asset_update.html
apps/assets/templates/assets/asset_update.html
+1
-0
apps/assets/views.py
apps/assets/views.py
+5
-1
apps/perms/forms.py
apps/perms/forms.py
+10
-0
apps/perms/hands.py
apps/perms/hands.py
+7
-1
未找到文件。
apps/assets/forms.py
浏览文件 @
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
浏览文件 @
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
浏览文件 @
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
浏览文件 @
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
浏览文件 @
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
浏览文件 @
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
浏览文件 @
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
))
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录