Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
gjl2004yn
jumpserver
提交
c58725db
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,发现更多精彩内容 >>
提交
c58725db
编写于
9月 09, 2016
作者:
baltery
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Finish system user view
上级
292179d4
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
543 addition
and
11 deletion
+543
-11
apps/assets/forms.py
apps/assets/forms.py
+1
-1
apps/assets/templates/assets/system_user_asset.html
apps/assets/templates/assets/system_user_asset.html
+139
-0
apps/assets/templates/assets/system_user_asset_group.html
apps/assets/templates/assets/system_user_asset_group.html
+140
-0
apps/assets/templates/assets/system_user_detail.html
apps/assets/templates/assets/system_user_detail.html
+192
-0
apps/assets/templates/assets/system_user_list.html
apps/assets/templates/assets/system_user_list.html
+2
-2
apps/assets/urls.py
apps/assets/urls.py
+3
-0
apps/assets/views.py
apps/assets/views.py
+66
-8
未找到文件。
apps/assets/forms.py
浏览文件 @
c58725db
...
...
@@ -155,7 +155,7 @@ class SystemUserForm(forms.ModelForm):
attrs
=
{
'class'
:
'select2'
,
'data-placeholder'
:
_
(
'Select asset groups'
)})
)
auto_generate_key
=
forms
.
BooleanField
(
required
=
True
,
initial
=
True
)
auto_generate_key
=
forms
.
BooleanField
(
initial
=
True
)
# Form field name can not start with `_`, so redefine it,
password
=
forms
.
CharField
(
widget
=
forms
.
PasswordInput
,
max_length
=
100
,
min_length
=
8
,
strip
=
True
,
help_text
=
_
(
'If also set private key, use that first'
),
required
=
False
)
...
...
apps/assets/templates/assets/system_user_asset.html
0 → 100644
浏览文件 @
c58725db
{% extends 'base.html' %}
{% load common_tags %}
{% load users_tags %}
{% load static %}
{% load i18n %}
{% block custom_head_css_js %}
<link
href=
"{% static "
css
/
plugins
/
select2
/
select2.min.css
"
%}"
rel=
"stylesheet"
>
<script
src=
"{% static "
js
/
plugins
/
select2
/
select2.full.min.js
"
%}"
></script>
{% endblock %}
{% block content %}
<div
class=
"wrapper wrapper-content animated fadeInRight"
>
<div
class=
"row"
>
<div
class=
"col-sm-12"
>
<div
class=
"ibox float-e-margins"
>
<div
class=
"panel-options"
>
<ul
class=
"nav nav-tabs"
>
<li>
<a
href=
"{% url 'assets:system-user-detail' pk=system_user.id %}"
class=
"text-center"
><i
class=
"fa fa-laptop"
></i>
{% trans 'Detail' %}
</a>
</li>
<li
class=
"active"
><a
href=
"{% url 'assets:system-user-asset' pk=system_user.id %}"
class=
"text-center"
>
<i
class=
"fa fa-bar-chart-o"
></i>
{% trans 'Associate assets' %}
</a>
</li>
<li><a
href=
"{% url 'assets:system-user-asset-group' pk=system_user.id %}"
class=
"text-center"
>
<i
class=
"fa fa-bar-chart-o"
></i>
{% trans 'Associate asset groups' %}
</a>
</li>
</ul>
</div>
<div
class=
"tab-content"
>
<div
class=
"col-sm-7"
style=
"padding-left: 0;"
>
<div
class=
"ibox float-e-margins"
>
<div
class=
"ibox-title"
>
<span
style=
"float: left"
>
{% trans 'Asset list of ' %}
<b>
{{ admin_user.name }}
</b></span>
<div
class=
"ibox-tools"
>
<a
class=
"collapse-link"
>
<i
class=
"fa fa-chevron-up"
></i>
</a>
<a
class=
"dropdown-toggle"
data-toggle=
"dropdown"
href=
"#"
>
<i
class=
"fa fa-wrench"
></i>
</a>
<ul
class=
"dropdown-menu dropdown-user"
>
<li><a
href=
"#"
></a>
</li>
<li><a
href=
"#"
></a>
</li>
</ul>
<a
class=
"close-link"
>
<i
class=
"fa fa-times"
></i>
</a>
</div>
</div>
<div
class=
"ibox-content"
>
<table
class=
"table table-hover"
>
<thead>
<tr>
<th>
{% trans 'Hostname' %}
</th>
<th>
{% trans 'IP' %}
</th>
<th>
{% trans 'Port' %}
</th>
<th>
{% trans 'Alive' %}
</th>
</tr>
</thead>
<tbody>
{% for asset in page_obj %}
<tr>
<td>
{{ asset.hostname }}
</td>
<td>
{{ asset.ip }}
</td>
<td>
{{ asset.port }}
</td>
<td>
Alive
</td>
</tr>
{% endfor %}
</tbody>
</table>
<div
class=
"row"
>
{% include '_pagination.html' %}
</div>
</div>
</div>
</div>
<div
class=
"col-sm-5"
style=
"padding-left: 0;padding-right: 0"
>
<div
class=
"panel panel-primary"
>
<div
class=
"panel-heading"
>
<i
class=
"fa fa-info-circle"
></i>
{% trans 'Add asset to this system user' %}
</div>
<div
class=
"panel-body"
>
<table
class=
"table"
>
<tbody>
<form>
<tr
class=
"no-borders-tr"
>
<td
colspan=
"2"
>
<select
data-placeholder=
"{% trans 'Select asset' %}"
class=
"select2"
style=
"width: 100%"
multiple=
""
tabindex=
"4"
>
{% for asset in assets %}
<option
value=
"{{ asset.id }}"
>
{{ asset.ip}}:{{ asset.port }}
</option>
{% endfor %}
</select>
</td>
</tr>
<tr
class=
"no-borders-tr"
>
<td
colspan=
"2"
>
<button
type=
"button"
class=
"btn btn-primary btn-sm"
>
{% trans 'Add' %}
</button>
</td>
</tr>
</form>
</tbody>
</table>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
{% endblock %}
{% block custom_foot_js %}
<script>
{
#
function
switch_user_status
(
obj
)
{
#
}
{
#
var
status
=
$
(
obj
).
prop
(
'
checked
'
);
#
}
{
##
}
{
#
$
.
ajax
({
#
}
{
#
url
:
"
{% url 'users:user-active-api' pk=user.id %}
"
,
#
}
{
#
type
:
"
PUT
"
,
#
}
{
#
data
:
{
#
}
{
#
'
is_active
'
:
status
#
}
{
#
},
#
}
{
#
success
:
function
(
data
,
status
)
{
#
}
{
#
console
.
log
(
data
)
#
}
{
#
},
#
}
{
#
error
:
function
()
{
#
}
{
#
console
.
log
(
'
error
'
)
#
}
{
#
}
#
}
{
#
})
#
}
{
#
}
#
}
$
(
document
).
ready
(
function
()
{
$
(
'
.select2
'
).
select2
();
});
</script>
{% endblock %}
\ No newline at end of file
apps/assets/templates/assets/system_user_asset_group.html
0 → 100644
浏览文件 @
c58725db
{% extends 'base.html' %}
{% load common_tags %}
{% load users_tags %}
{% load static %}
{% load i18n %}
{% block custom_head_css_js %}
<link
href=
"{% static "
css
/
plugins
/
select2
/
select2.min.css
"
%}"
rel=
"stylesheet"
>
<script
src=
"{% static "
js
/
plugins
/
select2
/
select2.full.min.js
"
%}"
></script>
{% endblock %}
{% block content %}
<div
class=
"wrapper wrapper-content animated fadeInRight"
>
<div
class=
"row"
>
<div
class=
"col-sm-12"
>
<div
class=
"ibox float-e-margins"
>
<div
class=
"panel-options"
>
<ul
class=
"nav nav-tabs"
>
<li>
<a
href=
"{% url 'assets:system-user-detail' pk=system_user.id %}"
class=
"text-center"
><i
class=
"fa fa-laptop"
></i>
{% trans 'Detail' %}
</a>
</li>
<li><a
href=
"{% url 'assets:system-user-asset' pk=system_user.id %}"
class=
"text-center"
>
<i
class=
"fa fa-bar-chart-o"
></i>
{% trans 'Associate assets' %}
</a>
</li>
<li
class=
"active"
>
<a
href=
"{% url 'assets:system-user-asset-group' pk=system_user.id %}"
class=
"text-center"
>
<i
class=
"fa fa-bar-chart-o"
></i>
{% trans 'Associate asset groups' %}
</a>
</li>
</ul>
</div>
<div
class=
"tab-content"
>
<div
class=
"col-sm-7"
style=
"padding-left: 0;"
>
<div
class=
"ibox float-e-margins"
>
<div
class=
"ibox-title"
>
<span
style=
"float: left"
>
{% trans 'Asset list of ' %}
<b>
{{ admin_user.name }}
</b></span>
<div
class=
"ibox-tools"
>
<a
class=
"collapse-link"
>
<i
class=
"fa fa-chevron-up"
></i>
</a>
<a
class=
"dropdown-toggle"
data-toggle=
"dropdown"
href=
"#"
>
<i
class=
"fa fa-wrench"
></i>
</a>
<ul
class=
"dropdown-menu dropdown-user"
>
<li><a
href=
"#"
></a>
</li>
<li><a
href=
"#"
></a>
</li>
</ul>
<a
class=
"close-link"
>
<i
class=
"fa fa-times"
></i>
</a>
</div>
</div>
<div
class=
"ibox-content"
>
<table
class=
"table table-hover"
>
<thead>
<tr>
<th>
{% trans 'Name' %}
</th>
<th>
{% trans 'Asset num' %}
</th>
<th>
{% trans 'Unavailable num' %}
</th>
<th>
{% trans 'Comment' %}
</th>
</tr>
</thead>
<tbody>
{% for asset_group in page_obj %}
<tr>
<td>
{{ asset_group.name }}
</td>
<td>
{{ asset_group_group.assets.count }}
</td>
<td>
{{ asset_group_group.assets.count }}
</td>
<td>
{{ asset_group.comment|truncatewords:4 }}
</td>
</tr>
{% endfor %}
</tbody>
</table>
<div
class=
"row"
>
{% include '_pagination.html' %}
</div>
</div>
</div>
</div>
<div
class=
"col-sm-5"
style=
"padding-left: 0;padding-right: 0"
>
<div
class=
"panel panel-primary"
>
<div
class=
"panel-heading"
>
<i
class=
"fa fa-info-circle"
></i>
{% trans 'Add asset group to this system user' %}
</div>
<div
class=
"panel-body"
>
<table
class=
"table"
>
<tbody>
<form>
<tr
class=
"no-borders-tr"
>
<td
colspan=
"2"
>
<select
data-placeholder=
"{% trans 'Select asset group' %}"
class=
"select2"
style=
"width: 100%"
multiple=
""
tabindex=
"4"
>
{% for asset_group in asset_groups %}
<option
value=
"{{ asset_group.id }}"
>
{{ asset_group.name}}
</option>
{% endfor %}
</select>
</td>
</tr>
<tr
class=
"no-borders-tr"
>
<td
colspan=
"2"
>
<button
type=
"button"
class=
"btn btn-primary btn-sm"
>
{% trans 'Add' %}
</button>
</td>
</tr>
</form>
</tbody>
</table>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
{% endblock %}
{% block custom_foot_js %}
<script>
{
#
function
switch_user_status
(
obj
)
{
#
}
{
#
var
status
=
$
(
obj
).
prop
(
'
checked
'
);
#
}
{
##
}
{
#
$
.
ajax
({
#
}
{
#
url
:
"
{% url 'users:user-active-api' pk=user.id %}
"
,
#
}
{
#
type
:
"
PUT
"
,
#
}
{
#
data
:
{
#
}
{
#
'
is_active
'
:
status
#
}
{
#
},
#
}
{
#
success
:
function
(
data
,
status
)
{
#
}
{
#
console
.
log
(
data
)
#
}
{
#
},
#
}
{
#
error
:
function
()
{
#
}
{
#
console
.
log
(
'
error
'
)
#
}
{
#
}
#
}
{
#
})
#
}
{
#
}
#
}
$
(
document
).
ready
(
function
()
{
$
(
'
.select2
'
).
select2
();
});
</script>
{% endblock %}
\ No newline at end of file
apps/assets/templates/assets/system_user_detail.html
0 → 100644
浏览文件 @
c58725db
{% extends 'base.html' %}
{% load common_tags %}
{% load users_tags %}
{% load static %}
{% load i18n %}
{% block custom_head_css_js %}
<link
href=
"{% static "
css
/
plugins
/
select2
/
select2.min.css
"
%}"
rel=
"stylesheet"
>
<script
src=
"{% static "
js
/
plugins
/
select2
/
select2.full.min.js
"
%}"
></script>
{% endblock %}
{% block content %}
<div
class=
"wrapper wrapper-content animated fadeInRight"
>
<div
class=
"row"
>
<div
class=
"col-sm-12"
>
<div
class=
"ibox float-e-margins"
>
<div
class=
"panel-options"
>
<ul
class=
"nav nav-tabs"
>
<li
class=
"active"
>
<a
href=
"{% url 'assets:system-user-detail' pk=system_user.id %}"
class=
"text-center"
><i
class=
"fa fa-laptop"
></i>
{% trans 'Detail' %}
</a>
</li>
<li>
<a
href=
"{% url 'assets:system-user-asset' pk=system_user.id %}"
class=
"text-center"
>
<i
class=
"fa fa-bar-chart-o"
></i>
{% trans 'Associate assets' %}
</a>
</li>
<li>
<a
href=
"{% url 'assets:system-user-asset-group' pk=system_user.id %}"
class=
"text-center"
>
<i
class=
"fa fa-bar-chart-o"
></i>
{% trans 'Associate asset groups' %}
</a>
</li>
</ul>
</div>
<div
class=
"tab-content"
>
<div
class=
"col-sm-7"
style=
"padding-left: 0;"
>
<div
class=
"ibox float-e-margins"
>
<div
class=
"ibox-title"
>
<span
class=
"label"
><b>
{{ system_user.name }}
</b></span>
<div
class=
"ibox-tools"
>
<a
class=
"collapse-link"
>
<i
class=
"fa fa-chevron-up"
></i>
</a>
<a
class=
"dropdown-toggle"
data-toggle=
"dropdown"
href=
"#"
>
<i
class=
"fa fa-wrench"
></i>
</a>
<ul
class=
"dropdown-menu dropdown-user"
>
<li><a
href=
"#"
></a>
</li>
<li><a
href=
"#"
></a>
</li>
</ul>
<a
class=
"close-link"
>
<i
class=
"fa fa-times"
></i>
</a>
</div>
</div>
<div
class=
"ibox-content"
>
<table
class=
"table"
>
<tbody>
<tr
class=
"no-borders-tr"
>
<td>
{% trans 'Name' %}:
</td>
<td><b>
{{ system_user.name }}
</b></td>
</tr>
<tr>
<td>
{% trans 'Username' %}:
</td>
<td><b>
{{ system_user.username }}
</b></td>
</tr>
<tr>
<td>
{% trans 'Protocol' %}:
</td>
<td><b>
{{ system_user.protocol }}
</b></td>
</tr>
<tr>
<td>
{% trans 'Auto push' %}:
</td>
<td><b>
{{ system_user.protocol }}
</b></td>
</tr>
<tr>
<td>
{% trans 'Auto update' %}:
</td>
<td><b>
{{ system_user.auto_update }}
</b></td>
</tr>
<tr>
<td>
{% trans 'As default' %}:
</td>
<td><b>
{{ system_user.protocol }}
</b></td>
</tr>
<tr>
<td>
{% trans 'Sudo' %}:
</td>
<td><b>
{{ system_user.sudo }}
</b></td>
</tr>
{% if system_user.shell %}
<tr>
<td>
{% trans 'Shell' %}:
</td>
<td><b>
{{ system_user.shell }}
</b></td>
</tr>
{% endif %}
{% if system_user.home %}
<tr>
<td>
{% trans 'Home' %}:
</td>
<td><b>
{{ system_user.home }}
</b></td>
</tr>
{% endif %}
{% if system_user.uid %}
<tr>
<td>
{% trans 'Uid' %}:
</td>
<td><b>
{{ system_user.uid }}
</b></td>
</tr>
{% endif %}
<tr>
<td>
{% trans 'Date created' %}:
</td>
<td><b>
{{ system_user.date_created }}
</b></td>
</tr>
<tr>
<td>
{% trans 'Created by' %}:
</td>
<td><b>
{{ asset_group.created_by }}
</b></td>
</tr>
<tr>
<td>
{% trans 'Comment' %}:
</td>
<td><b>
{{ system_user.comment }}
</b></td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
<div
class=
"col-sm-5"
style=
"padding-left: 0;padding-right: 0"
>
<div
class=
"panel panel-primary"
>
<div
class=
"panel-heading"
>
<i
class=
"fa fa-info-circle"
></i>
{% trans 'Quick update' %}
</div>
<div
class=
"panel-body"
>
<table
class=
"table"
>
<tbody>
<tr
class=
"no-borders-tr"
>
<td
width=
"50%"
>
{% trans 'Get mannual install script' %}:
</td>
<td>
<span
style=
"float: right"
>
<button
type=
"button"
class=
"btn btn-primary btn-xs"
style=
"width: 54px"
>
{% trans 'Get' %}
</button>
</span>
</td>
</tr>
<tr>
<td
width=
"50%"
>
{% trans 'Retest asset connectivity' %}:
</td>
<td>
<span
style=
"float: right"
>
<button
type=
"button"
class=
"btn btn-primary btn-xs"
style=
"width: 54px"
>
{% trans 'Start' %}
</button>
</span>
</td>
</tr>
<tr>
<td
width=
"50%"
>
{% trans 'Reset private key' %}:
</td>
<td>
<span
style=
"float: right"
>
<button
type=
"button"
class=
"btn btn-primary btn-xs"
style=
"width: 54px"
>
{% trans 'Reset' %}
</button>
</span>
</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
{% endblock %}
{% block custom_foot_js %}
<script>
{
#
function
switch_user_status
(
obj
)
{
#
}
{
#
var
status
=
$
(
obj
).
prop
(
'
checked
'
);
#
}
{
##
}
{
#
$
.
ajax
({
#
}
{
#
url
:
"
{% url 'users:user-active-api' pk=user.id %}
"
,
#
}
{
#
type
:
"
PUT
"
,
#
}
{
#
data
:
{
#
}
{
#
'
is_active
'
:
status
#
}
{
#
},
#
}
{
#
success
:
function
(
data
,
status
)
{
#
}
{
#
console
.
log
(
data
)
#
}
{
#
},
#
}
{
#
error
:
function
()
{
#
}
{
#
console
.
log
(
'
error
'
)
#
}
{
#
}
#
}
{
#
})
#
}
{
#
}
#
}
$
(
document
).
ready
(
function
()
{
$
(
'
.select2
'
).
select2
();
});
</script>
{% endblock %}
\ No newline at end of file
apps/assets/templates/assets/system_user_list.html
浏览文件 @
c58725db
...
...
@@ -11,7 +11,7 @@
<th
class=
"text-center"
><a
href=
"{% url 'assets:system-user-list' %}?sort=username"
>
{% trans 'Username' %}
</a></th>
<th
class=
"text-center"
>
{% trans 'Asset num' %}
</th>
<th
class=
"text-center"
>
{% trans 'Asset group num' %}
</th>
<th
class=
"text-center"
>
{% trans '
Lost connection
' %}
</th>
<th
class=
"text-center"
>
{% trans '
Unavailable
' %}
</th>
<th
class=
"text-center"
>
{% trans 'Comment' %}
</th>
<th
class=
"text-center"
></th>
{% endblock %}
...
...
@@ -29,7 +29,7 @@
<td
class=
"text-center"
>
{{ system_user.assets.count }}
</td>
<td
class=
"text-center"
>
{{ system_user.asset_groups.count }}
</td>
<td
class=
"text-center"
>
{{ system_user.assets.count }}
</td>
<td
class=
"text-center"
>
{{ system_user.comment|truncatewords:
8
}}
</td>
<td
class=
"text-center"
>
{{ system_user.comment|truncatewords:
4
}}
</td>
<td
class=
"text-center"
>
<!-- Todo: Click script button will paste a url to clipboard like: curl http://url/system_user_create.sh | bash -->
<a
href=
"{% url 'assets:system-user-update' pk=system_user.id %}"
class=
"btn btn-xs btn-primary"
>
{% trans 'Script' %}
</a>
...
...
apps/assets/urls.py
浏览文件 @
c58725db
...
...
@@ -38,5 +38,8 @@ urlpatterns = [
url
(
r
'^system-user/(?P<pk>[0-9]+)$'
,
views
.
SystemUserDetailView
.
as_view
(),
name
=
'system-user-detail'
),
url
(
r
'^system-user/(?P<pk>[0-9]+)/update'
,
views
.
SystemUserUpdateView
.
as_view
(),
name
=
'system-user-update'
),
url
(
r
'^system-user/(?P<pk>[0-9]+)/delete$'
,
views
.
SystemUserDeleteView
.
as_view
(),
name
=
'system-user-delete'
),
url
(
r
'^system-user/(?P<pk>[0-9]+)/asset$'
,
views
.
SystemUserAssetView
.
as_view
(),
name
=
'system-user-asset'
),
url
(
r
'^system-user/(?P<pk>[0-9]+)/asset-group$'
,
views
.
SystemUserAssetGroupView
.
as_view
(),
name
=
'system-user-asset-group'
),
# url(r'^api/v1.0/', include(router.urls)),
]
apps/assets/views.py
浏览文件 @
c58725db
...
...
@@ -335,8 +335,8 @@ class SystemUserCreateView(AdminUserRequiredMixin, SuccessMessageMixin, CreateVi
def
get_context_data
(
self
,
**
kwargs
):
context
=
{
'app'
:
'assets'
,
'action'
:
'Create system user'
'app'
:
_
(
'Assets'
)
,
'action'
:
_
(
'Create system user'
),
}
kwargs
.
update
(
context
)
return
super
(
SystemUserCreateView
,
self
).
get_context_data
(
**
kwargs
)
...
...
@@ -356,8 +356,8 @@ class SystemUserUpdateView(AdminUserRequiredMixin, UpdateView):
def
get_context_data
(
self
,
**
kwargs
):
context
=
{
'app'
:
'assets'
,
'action'
:
'Update system user'
'app'
:
_
(
'Assets'
)
,
'action'
:
_
(
'Update system user'
)
}
kwargs
.
update
(
context
)
return
super
(
SystemUserUpdateView
,
self
).
get_context_data
(
**
kwargs
)
...
...
@@ -367,10 +367,68 @@ class SystemUserUpdateView(AdminUserRequiredMixin, UpdateView):
return
success_url
class
SystemUserDetailView
(
DetailView
):
pass
class
SystemUserDetailView
(
AdminUserRequiredMixin
,
DetailView
):
template_name
=
'assets/system_user_detail.html'
context_object_name
=
'system_user'
model
=
SystemUser
def
get_context_data
(
self
,
**
kwargs
):
context
=
{
'app'
:
_
(
'Assets'
),
'action'
:
_
(
'System user detail'
)
}
kwargs
.
update
(
context
)
return
super
(
SystemUserDetailView
,
self
).
get_context_data
(
**
kwargs
)
class
SystemUserDeleteView
(
DeleteView
):
pass
class
SystemUserDeleteView
(
AdminUserRequiredMixin
,
DeleteView
):
model
=
SystemUser
template_name
=
'assets/delete_confirm.html'
success_url
=
'assets:system-user-list'
class
SystemUserAssetView
(
AdminUserRequiredMixin
,
SingleObjectMixin
,
ListView
):
paginate_by
=
settings
.
CONFIG
.
DISPLAY_PER_PAGE
template_name
=
'assets/system_user_asset.html'
context_object_name
=
'system_user'
def
get
(
self
,
request
,
*
args
,
**
kwargs
):
self
.
object
=
self
.
get_object
(
queryset
=
SystemUser
.
objects
.
all
())
return
super
(
SystemUserAssetView
,
self
).
get
(
request
,
*
args
,
**
kwargs
)
# Todo: queryset default order by connectivity, need ops support
def
get_queryset
(
self
):
return
self
.
object
.
assets
.
all
()
def
get_context_data
(
self
,
**
kwargs
):
context
=
{
'app'
:
'assets'
,
'action'
:
'System user asset'
,
'assets'
:
self
.
get_queryset
(),
}
kwargs
.
update
(
context
)
return
super
(
SystemUserAssetView
,
self
).
get_context_data
(
**
kwargs
)
class
SystemUserAssetGroupView
(
AdminUserRequiredMixin
,
SingleObjectMixin
,
ListView
):
paginate_by
=
settings
.
CONFIG
.
DISPLAY_PER_PAGE
template_name
=
'assets/system_user_asset_group.html'
context_object_name
=
'system_user'
def
get
(
self
,
request
,
*
args
,
**
kwargs
):
self
.
object
=
self
.
get_object
(
queryset
=
SystemUser
.
objects
.
all
())
return
super
(
SystemUserAssetGroupView
,
self
).
get
(
request
,
*
args
,
**
kwargs
)
# Todo: queryset default order by connectivity, need ops support
def
get_queryset
(
self
):
return
self
.
object
.
asset_groups
.
all
()
def
get_context_data
(
self
,
**
kwargs
):
context
=
{
'app'
:
'assets'
,
'action'
:
'System user asset group'
,
'asset_groups'
:
self
.
get_queryset
(),
}
kwargs
.
update
(
context
)
return
super
(
SystemUserAssetGroupView
,
self
).
get_context_data
(
**
kwargs
)
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录