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
3a297302
Commit
3a297302
authored
May 29, 2018
by
BaiJiangJie
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[Update] 修改资产树和资产列表数量显示(游离资产)
parent
7b57d24d
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
11 additions
and
7 deletions
+11
-7
asset.py
apps/assets/api/asset.py
+7
-5
_asset_list_modal.html
apps/assets/templates/assets/_asset_list_modal.html
+1
-1
login.py
apps/users/views/login.py
+3
-1
No files found.
apps/assets/api/asset.py
View file @
3a297302
...
@@ -50,16 +50,18 @@ class AssetViewSet(IDInFilterMixin, LabelFilter, BulkModelViewSet):
...
@@ -50,16 +50,18 @@ class AssetViewSet(IDInFilterMixin, LabelFilter, BulkModelViewSet):
queryset
=
queryset
.
filter
(
admin_user
=
admin_user
)
queryset
=
queryset
.
filter
(
admin_user
=
admin_user
)
if
node_id
and
show_current_asset
:
if
node_id
and
show_current_asset
:
node
=
get_object_or_404
(
Node
,
id
=
node_id
)
if
node
.
is_root
():
queryset
=
queryset
.
filter
(
queryset
=
queryset
.
filter
(
Q
(
nodes
=
node_id
)
|
Q
(
nodes__isnull
=
True
)
Q
(
nodes
=
node_id
)
|
Q
(
nodes__isnull
=
True
)
)
.
distinct
()
)
.
distinct
()
else
:
queryset
=
queryset
.
filter
(
nodes
=
node
)
.
distinct
()
if
node_id
and
not
show_current_asset
:
if
node_id
and
not
show_current_asset
:
node
=
get_object_or_404
(
Node
,
id
=
node_id
)
node
=
get_object_or_404
(
Node
,
id
=
node_id
)
if
not
node
.
is_root
():
if
node
.
is_root
():
queryset
=
queryset
.
filter
(
queryset
=
Asset
.
objects
.
all
()
Q
(
nodes__key__regex
=
'^{}(:[0-9]+)*$'
.
format
(
node
.
key
))
|
Q
(
nodes__isnull
=
True
),
)
.
distinct
()
else
:
else
:
queryset
=
queryset
.
filter
(
queryset
=
queryset
.
filter
(
nodes__key__regex
=
'^{}(:[0-9]+)*$'
.
format
(
node
.
key
),
nodes__key__regex
=
'^{}(:[0-9]+)*$'
.
format
(
node
.
key
),
...
...
apps/assets/templates/assets/_asset_list_modal.html
View file @
3a297302
...
@@ -95,7 +95,7 @@ function initTree2() {
...
@@ -95,7 +95,7 @@ function initTree2() {
};
};
var
zNodes
=
[];
var
zNodes
=
[];
$
.
get
(
"{% url 'api-assets:node-list' %}"
,
function
(
data
,
status
){
$
.
get
(
"{% url 'api-assets:node-list' %}
?show_current_asset=1
"
,
function
(
data
,
status
){
$
.
each
(
data
,
function
(
index
,
value
)
{
$
.
each
(
data
,
function
(
index
,
value
)
{
value
[
"pId"
]
=
value
[
"parent"
];
value
[
"pId"
]
=
value
[
"parent"
];
{
#
value
[
"open"
]
=
true
;
#
}
{
#
value
[
"open"
]
=
true
;
#
}
...
...
apps/users/views/login.py
View file @
3a297302
...
@@ -50,7 +50,9 @@ class UserLoginView(FormView):
...
@@ -50,7 +50,9 @@ class UserLoginView(FormView):
def
get
(
self
,
request
,
*
args
,
**
kwargs
):
def
get
(
self
,
request
,
*
args
,
**
kwargs
):
if
request
.
user
.
is_staff
:
if
request
.
user
.
is_staff
:
return
redirect
(
self
.
get_success_url
())
return
redirect
(
redirect_user_first_login_or_index
(
request
,
self
.
redirect_field_name
)
)
request
.
session
.
set_test_cookie
()
request
.
session
.
set_test_cookie
()
return
super
()
.
get
(
request
,
*
args
,
**
kwargs
)
return
super
()
.
get
(
request
,
*
args
,
**
kwargs
)
...
...
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