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
e78d7b02
Commit
e78d7b02
authored
Dec 06, 2015
by
wangyong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
cu asset page and sth
parent
b346e1c4
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
24 additions
and
14 deletions
+24
-14
asset_api.py
jasset/asset_api.py
+2
-2
views.py
jasset/views.py
+15
-5
asset_cu_list.html
templates/jasset/asset_cu_list.html
+0
-0
asset_list.html
templates/jasset/asset_list.html
+7
-7
No files found.
jasset/asset_api.py
View file @
e78d7b02
...
...
@@ -213,8 +213,8 @@ def write_excel(asset_all):
group_all
=
'/'
.
join
(
group_list
)
status
=
asset
.
get_status_display
()
idc_name
=
asset
.
idc
.
name
if
asset
.
idc
else
u''
system_type
=
asset
.
system_type
if
asset
.
idc
else
u''
system_version
=
asset
.
system_version
if
asset
.
idc
else
u''
system_type
=
asset
.
system_type
if
asset
.
system_type
else
u''
system_version
=
asset
.
system_version
if
asset
.
system_version
else
u''
system_os
=
unicode
(
system_type
)
+
unicode
(
system_version
)
alter_dic
=
[
asset
.
hostname
,
asset
.
ip
,
idc_name
,
group_all
,
system_os
,
asset
.
cpu
,
asset
.
memory
,
...
...
jasset/views.py
View file @
e78d7b02
...
...
@@ -6,9 +6,7 @@ from jumpserver.api import *
from
jumpserver.models
import
Setting
from
jasset.forms
import
AssetForm
,
IdcForm
from
jasset.models
import
Asset
,
IDC
,
AssetGroup
,
ASSET_TYPE
,
ASSET_STATUS
from
jperm.perm_api
import
get_group_asset_perm
from
jperm.ansible_api
import
MyRunner
from
jperm.perm_api
import
gen_resource
from
jperm.perm_api
import
get_group_asset_perm
,
get_group_user_perm
@require_role
(
'admin'
)
...
...
@@ -169,7 +167,7 @@ def asset_add(request):
@require_role
(
'admin'
)
def
asset_add_batch
(
request
):
header_title
,
path1
,
path2
=
u'添加资产'
,
u'资产管理'
,
u'批量添加'
return
my_render
(
'jasset/
asset
_add_batch.html'
,
locals
(),
request
)
return
my_render
(
'jasset/
server
_add_batch.html'
,
locals
(),
request
)
@require_role
(
'admin'
)
...
...
@@ -259,6 +257,8 @@ def asset_list(request):
asset list view
"""
header_title
,
path1
,
path2
=
u'查看资产'
,
u'资产管理'
,
u'查看资产'
username
=
request
.
user
.
username
user_perm
=
request
.
session
[
'role_id'
]
idc_all
=
IDC
.
objects
.
filter
()
asset_group_all
=
AssetGroup
.
objects
.
all
()
asset_types
=
ASSET_TYPE
...
...
@@ -282,12 +282,19 @@ def asset_list(request):
if
idc
:
asset_find
=
Asset
.
objects
.
filter
(
idc
=
idc
)
else
:
if
user_perm
!=
0
:
asset_find
=
Asset
.
objects
.
all
()
else
:
user
=
get_object
(
User
,
username
=
username
)
asset_perm
=
get_group_user_perm
(
user
)
if
user
else
{
'asset'
:
''
}
asset_find
=
asset_perm
[
'asset'
]
.
keys
()
asset_group_all
=
list
(
asset_perm
[
'asset_group'
])
if
idc_name
:
asset_find
=
asset_find
.
filter
(
idc__name__contains
=
idc_name
)
if
group_name
:
print
asset_find
,
type
(
asset_find
)
asset_find
=
asset_find
.
filter
(
group__name__contains
=
group_name
)
if
asset_type
:
...
...
@@ -324,7 +331,10 @@ def asset_list(request):
smg
=
u'excel文件已生成,请点击下载!'
return
my_render
(
'jasset/asset_excel_download.html'
,
locals
(),
request
)
assets_list
,
p
,
assets
,
page_range
,
current_page
,
show_first
,
show_end
=
pages
(
asset_find
,
request
)
if
user_perm
!=
0
:
return
my_render
(
'jasset/asset_list.html'
,
locals
(),
request
)
else
:
return
my_render
(
'jasset/asset_cu_list.html'
,
locals
(),
request
)
@require_role
(
'admin'
)
...
...
@@ -551,4 +561,4 @@ def asset_upload(request):
smg
=
u'批量添加成功'
else
:
emg
=
u'批量添加失败,请检查格式.'
return
my_render
(
'jasset/
asset
_add_batch.html'
,
locals
(),
request
)
return
my_render
(
'jasset/
server
_add_batch.html'
,
locals
(),
request
)
templates/jasset/asset_cu_list.html
0 → 100644
View file @
e78d7b02
This diff is collapsed.
Click to expand it.
templates/jasset/asset_list.html
View file @
e78d7b02
...
...
@@ -30,7 +30,7 @@
<div
class=
"col-sm-7"
style=
"padding-left: 0px"
>
<label>
<select
name=
"idc"
class=
"form-control m-b"
onchange=
"change_info()"
>
<select
name=
"idc"
class=
"form-control m-b
input-sm
"
onchange=
"change_info()"
>
<option
value=
""
>
机房
</option>
{% for idc in idc_all %}
{% ifequal idc.name idc_name %}
...
...
@@ -43,7 +43,7 @@
</label>
<label>
<select
name=
"group"
class=
"form-control m-b"
onchange=
"change_info()"
>
<select
name=
"group"
class=
"form-control m-b
input-sm
"
onchange=
"change_info()"
>
<option
value=
""
>
主机组
</option>
{% for asset_group in asset_group_all %}
{% ifequal asset_group.name group_name %}
...
...
@@ -56,7 +56,7 @@
</label>
<label>
<select
name=
"asset_type"
class=
"form-control m-b"
onchange=
"change_info()"
>
<select
name=
"asset_type"
class=
"form-control m-b
input-sm
"
onchange=
"change_info()"
>
<option
value=
""
>
资产类型
</option>
{% for type in asset_types %}
{% ifequal type.0|int2str asset_type %}
...
...
@@ -69,7 +69,7 @@
</label>
<label>
<select
name=
"status"
class=
"form-control m-b"
onchange=
"change_info()"
>
<select
name=
"status"
class=
"form-control m-b
input-sm
"
onchange=
"change_info()"
>
<option
value=
""
>
资产状态
</option>
{% for s in asset_status %}
{% ifequal s.0|int2str status %}
...
...
@@ -84,13 +84,13 @@
<div
class=
"col-sm-4"
style=
"padding-right: 0"
>
<div
class=
"input-group inline-group"
>
<input
type=
"text"
class=
"form-control m-b"
id=
"search_input"
name=
"keyword"
value=
"{{ keyword }}"
placeholder=
"Search"
>
<input
type=
"text"
class=
"form-control m-b
input-sm
"
id=
"search_input"
name=
"keyword"
value=
"{{ keyword }}"
placeholder=
"Search"
>
<input
type=
"text"
style=
"display: none"
>
<div
class=
"input-group-btn"
>
<button
id=
'search_btn'
href=
"/jasset/asset_list/?search=true"
type=
"button"
class=
"btn btn-
x
m btn-primary search-btn"
onclick=
"change_info()"
>
<button
id=
'search_btn'
href=
"/jasset/asset_list/?search=true"
type=
"button"
class=
"btn btn-
s
m btn-primary search-btn"
onclick=
"change_info()"
>
- 搜索 -
</button>
<button
type=
"button"
href=
"/jasset/asset_list/?export=true"
name=
"export"
class=
"btn btn-
x
m btn-success search-btn-excel"
onclick=
"return false"
>
<button
type=
"button"
href=
"/jasset/asset_list/?export=true"
name=
"export"
class=
"btn btn-
s
m btn-success search-btn-excel"
onclick=
"return false"
>
- 导出 -
</button>
</div>
...
...
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