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
c58725db
Commit
c58725db
authored
8 years ago
by
ibuler
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Finish system user view
parent
292179d4
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
546 additions
and
11 deletions
+546
-11
forms.py
apps/assets/forms.py
+1
-1
system_user_asset.html
apps/assets/templates/assets/system_user_asset.html
+140
-0
system_user_asset_group.html
apps/assets/templates/assets/system_user_asset_group.html
+141
-0
system_user_detail.html
apps/assets/templates/assets/system_user_detail.html
+193
-0
system_user_list.html
apps/assets/templates/assets/system_user_list.html
+2
-2
urls.py
apps/assets/urls.py
+3
-0
views.py
apps/assets/views.py
+66
-8
No files found.
apps/assets/forms.py
View file @
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
)
...
...
This diff is collapsed.
Click to expand it.
apps/assets/templates/assets/system_user_asset.html
0 → 100644
View file @
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
This diff is collapsed.
Click to expand it.
apps/assets/templates/assets/system_user_asset_group.html
0 → 100644
View file @
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
This diff is collapsed.
Click to expand it.
apps/assets/templates/assets/system_user_detail.html
0 → 100644
View file @
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
This diff is collapsed.
Click to expand it.
apps/assets/templates/assets/system_user_list.html
View file @
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>
...
...
This diff is collapsed.
Click to expand it.
apps/assets/urls.py
View file @
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)),
]
This diff is collapsed.
Click to expand it.
apps/assets/views.py
View file @
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
)
This diff is collapsed.
Click to expand it.
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