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
e873be95
Commit
e873be95
authored
Mar 26, 2018
by
ibuler
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[Update] 导入到当前node
parent
dbaa4ab5
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
12 additions
and
0 deletions
+12
-0
asset_list.html
apps/assets/templates/assets/asset_list.html
+8
-0
asset.py
apps/assets/views/asset.py
+4
-0
No files found.
apps/assets/templates/assets/asset_list.html
View file @
e873be95
...
...
@@ -451,6 +451,14 @@ $(document).ready(function(){
})
.
on
(
'click'
,
'#btn_asset_import'
,
function
()
{
var
$form
=
$
(
'#fm_asset_import'
);
var
action
=
$form
.
attr
(
"action"
);
var
nodes
=
zTree
.
getSelectedNodes
();
var
current_node
;
if
(
nodes
&&
nodes
.
length
===
1
){
current_node
=
nodes
[
0
];
action
+=
"?node_id="
+
current_node
.
id
;
$form
.
attr
(
"action"
,
action
)
}
$form
.
find
(
'.help-block'
).
remove
();
function
success
(
data
)
{
if
(
data
.
valid
===
false
)
{
...
...
apps/assets/views/asset.py
View file @
e873be95
...
...
@@ -245,6 +245,8 @@ class BulkImportAssetView(AdminUserRequiredMixin, JSONResponseMixin, FormView):
form_class
=
forms
.
FileForm
def
form_valid
(
self
,
form
):
node_id
=
self
.
request
.
GET
.
get
(
"node_id"
)
node
=
get_object_or_none
(
Node
,
id
=
node_id
)
if
node_id
else
Node
.
root
()
f
=
form
.
cleaned_data
[
'file'
]
det_result
=
chardet
.
detect
(
f
.
read
())
f
.
seek
(
0
)
# reset file seek index
...
...
@@ -297,6 +299,8 @@ class BulkImportAssetView(AdminUserRequiredMixin, JSONResponseMixin, FormView):
raise
Exception
(
_
(
'already exists'
))
with
transaction
.
atomic
():
asset
=
Asset
.
objects
.
create
(
**
asset_dict
)
if
node
:
asset
.
nodes
.
set
([
node
])
created
.
append
(
asset_dict
[
'hostname'
])
assets
.
append
(
asset
)
except
Exception
as
e
:
...
...
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