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
910dd4e5
Commit
910dd4e5
authored
Oct 16, 2018
by
ibuler
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[Update] 修改节点生成规则
parent
11aefa47
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
6 additions
and
7 deletions
+6
-7
node.py
apps/assets/models/node.py
+5
-3
asset.py
apps/assets/views/asset.py
+1
-4
No files found.
apps/assets/models/node.py
View file @
910dd4e5
...
...
@@ -203,12 +203,14 @@ class Node(OrgModelMixin):
# 如果使用current_org 在set_current_org时会死循环
_current_org
=
get_current_org
()
with
transaction
.
atomic
():
if
_current_org
.
is_
defaul
t
():
if
_current_org
.
is_
roo
t
():
key
=
'0'
elif
_current_org
.
is_default
():
key
=
'1'
else
:
set_current_org
(
Organization
.
root
())
org_nodes_roots
=
cls
.
objects
.
filter
(
key__regex
=
r'^[0-9]+$'
)
org_nodes_roots_keys
=
org_nodes_roots
.
values_list
(
'key'
,
flat
=
True
)
or
[
0
]
org_nodes_roots_keys
=
org_nodes_roots
.
values_list
(
'key'
,
flat
=
True
)
or
[
'1'
]
key
=
str
(
max
([
int
(
k
)
for
k
in
org_nodes_roots_keys
])
+
1
)
set_current_org
(
_current_org
)
root
=
cls
.
objects
.
create
(
key
=
key
,
value
=
_current_org
.
name
)
...
...
@@ -225,7 +227,7 @@ class Node(OrgModelMixin):
@classmethod
def
default_node
(
cls
):
defaults
=
{
'value'
:
'Default'
}
return
cls
.
objects
.
get_or_create
(
defaults
=
defaults
,
key
=
'
0
'
)
return
cls
.
objects
.
get_or_create
(
defaults
=
defaults
,
key
=
'
1
'
)
@classmethod
def
get_tree_name_ref
(
cls
):
...
...
apps/assets/views/asset.py
View file @
910dd4e5
...
...
@@ -45,10 +45,7 @@ class AssetListView(AdminUserRequiredMixin, TemplateView):
template_name
=
'assets/asset_list.html'
def
get_context_data
(
self
,
**
kwargs
):
if
current_org
.
is_default
():
Node
.
default_node
()
else
:
Node
.
root
()
Node
.
root
()
context
=
{
'app'
:
_
(
'Assets'
),
'action'
:
_
(
'Asset list'
),
...
...
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