Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
gjl2004yn
jumpserver
提交
df281def
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,发现更多精彩内容 >>
提交
df281def
编写于
9月 17, 2016
作者:
baltery
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Finish user detail asset grant ..
上级
7d3474ae
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
21 addition
and
12 deletion
+21
-12
apps/perms/utils.py
apps/perms/utils.py
+6
-1
apps/users/templates/users/user_granted_asset.html
apps/users/templates/users/user_granted_asset.html
+6
-7
apps/users/views.py
apps/users/views.py
+9
-4
未找到文件。
apps/perms/utils.py
浏览文件 @
df281def
...
...
@@ -7,7 +7,7 @@ def get_user_group_granted_asset_groups(user_group):
"""Return asset groups granted of the user group
:param user_group: Instance of :class: ``UserGroup``
:return: {asset
_group1: {system_user1, }, asset_group2
: {system_user1, system_user2]}
:return: {asset
1: {system_user1, }, asset1
: {system_user1, system_user2]}
"""
asset_groups
=
{}
asset_permissions
=
user_group
.
asset_permissions
.
all
()
...
...
@@ -61,6 +61,7 @@ def get_user_granted_asset_groups_direct(user):
if
asset_group
in
asset_groups
:
asset_groups
[
asset_group
]
|=
set
(
asset_permission
.
system_users
.
all
())
else
:
setattr
(
asset_group
,
'is_inherit_from_user_group'
,
False
)
asset_groups
[
asset_group
]
=
set
(
asset_permission
.
system_users
.
all
())
return
asset_groups
...
...
@@ -88,6 +89,7 @@ def get_user_granted_asset_groups_inherit_from_user_groups(user):
if
asset_group
in
asset_groups
:
asset_groups
[
asset_group
]
|=
set
(
asset_permission
.
system_users
.
all
())
else
:
setattr
(
asset_group
,
'is_inherit_from_user_group'
,
True
)
asset_groups
[
asset_group
]
=
set
(
asset_permission
.
system_users
.
all
())
return
asset_groups
...
...
@@ -130,6 +132,8 @@ def get_user_granted_assets_direct(user):
if
asset
in
assets
:
assets
[
asset
]
|=
set
(
asset_permission
.
system_users
.
all
())
else
:
setattr
(
asset
,
'is_inherit_from_user_groups'
,
False
)
setattr
(
asset
,
'is_inherit_from_user_groups'
,
False
)
assets
[
asset
]
=
set
(
asset_permission
.
system_users
.
all
())
return
assets
...
...
@@ -150,6 +154,7 @@ def get_user_granted_assets_inherit_from_user_groups(user):
if
asset
in
assets
:
assets
[
asset
]
|=
assets_inherited
[
asset
]
else
:
setattr
(
asset
,
'is_inherit_from_user_groups'
,
True
)
assets
[
asset
]
=
assets_inherited
[
asset
]
return
assets
...
...
apps/users/templates/users/user_granted_asset.html
浏览文件 @
df281def
...
...
@@ -74,7 +74,7 @@
</tr>
</thead>
<tbody>
{% for asset in object_list %}
{% for asset
, system_users
in object_list %}
<tr
class=
"gradeX"
>
<td
class=
"text-center"
>
<a
href=
"{% url 'assets:asset-detail' pk=asset.id %}"
>
...
...
@@ -83,7 +83,7 @@
</td>
<td
class=
"text-center"
>
{{ asset.ip }}
</td>
<td
class=
"text-center"
>
{{ asset.port }}
</td>
<td
class=
"text-center"
>
{{
assets.asset
}}
</td>
<td
class=
"text-center"
>
{{
system_users|join_attr:"name"
}}
</td>
<td
class=
"text-center"
>
{% if asset.is_valid %}
<i
class=
"fa fa-check text-navy"
></i>
...
...
@@ -92,8 +92,7 @@
{% endif %}
</td>
<td>
<button
class=
"btn btn-danger btn-xs btn_delete_user_group {% if not asset.is_valid %} disabled {% endif %}"
type=
"button"
style=
"float: right;"
><i
class=
"fa fa-minus"
></i></button>
</td>
<button
class=
"btn btn-danger btn-xs btn_delete_user_group {% if asset.is_inherit_from_user_groups or asset.is_inherit_from_asset_groups %} disabled {% endif %}"
type=
"button"
style=
"float: right;"
><i
class=
"fa fa-minus"
></i></button>
</td>
</tr>
{% endfor %}
...
...
@@ -134,7 +133,7 @@
</tr>
</thead>
<tbody>
{% for asset_group in asset_groups %}
{% for asset_group
, system_users
in asset_groups %}
<tr
class=
"gradeX"
>
<td
class=
"text-center"
>
<a
href=
"{% url 'assets:asset-group-detail' pk=asset_group.id %}"
>
...
...
@@ -142,9 +141,9 @@
</a>
</td>
<td
class=
"text-center"
>
{{ asset_group.assets.count }}
</td>
<td
class=
"text-center"
>
{{
asset_group.name
}}
</td>
<td
class=
"text-center"
>
{{
system_users|join_attr:"name"
}}
</td>
<td>
<button
class=
"btn btn-danger btn-xs btn_delete_user_group {% if not asset
.is_valid
%} disabled {% endif %}"
type=
"button"
style=
"float: right;"
><i
class=
"fa fa-minus"
></i></button>
<button
class=
"btn btn-danger btn-xs btn_delete_user_group {% if not asset
_group.is_inherit_from_user_groups
%} disabled {% endif %}"
type=
"button"
style=
"float: right;"
><i
class=
"fa fa-minus"
></i></button>
</td>
</tr>
{% endfor %}
...
...
apps/users/views.py
浏览文件 @
df281def
...
...
@@ -427,15 +427,20 @@ class UserGrantedAssetView(AdminUserRequiredMixin, SingleObjectMixin, ListView):
return
super
(
UserGrantedAssetView
,
self
).
get
(
request
,
*
args
,
**
kwargs
)
def
get_queryset
(
self
):
self
.
assets_granted
=
get_user_granted_assets
(
self
.
object
)
return
self
.
assets_granted
.
keys
()
# Convert format from {'asset': ['system_users'], ..} to
# [('asset', ['system_users']), ('asset', ['system_users']))
assets_granted
=
[(
asset
,
system_users
)
for
asset
,
system_users
in
get_user_granted_assets
(
self
.
object
).
items
()]
return
assets_granted
def
get_context_data
(
self
,
**
kwargs
):
asset_groups
=
[(
asset_group
,
system_users
)
for
asset_group
,
system_users
in
get_user_granted_asset_groups
(
self
.
object
).
items
()]
context
=
{
'app'
:
'User'
,
'action'
:
'User granted asset'
,
'asset_groups'
:
get_user_granted_asset_groups
(
self
.
object
),
'assets'
:
self
.
assets_granted
,
'asset_groups'
:
asset_groups
,
}
kwargs
.
update
(
context
)
return
super
(
UserGrantedAssetView
,
self
).
get_context_data
(
**
kwargs
)
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录