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
ae564ed0
Unverified
Commit
ae564ed0
authored
Aug 10, 2018
by
老广
Committed by
GitHub
Aug 10, 2018
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1670 from jumpserver/dev
Dev
parents
fa0bd85f
05ecd749
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
34 additions
and
19 deletions
+34
-19
node.py
apps/assets/api/node.py
+14
-6
node.py
apps/assets/models/node.py
+5
-0
node.py
apps/assets/serializers/node.py
+1
-1
asset_list.html
apps/assets/templates/assets/asset_list.html
+3
-1
asset.py
apps/assets/views/asset.py
+6
-3
django.mo
apps/i18n/zh/LC_MESSAGES/django.mo
+0
-0
django.po
apps/i18n/zh/LC_MESSAGES/django.po
+0
-0
settings.py
apps/jumpserver/settings.py
+5
-5
utils.py
apps/perms/utils.py
+0
-2
api.py
apps/terminal/api.py
+0
-1
No files found.
apps/assets/api/node.py
View file @
ae564ed0
...
...
@@ -43,15 +43,23 @@ class NodeViewSet(viewsets.ModelViewSet):
permission_classes
=
(
IsOrgAdmin
,)
serializer_class
=
serializers
.
NodeSerializer
def
get_queryset
(
self
):
queryset
=
super
()
.
get_queryset
()
.
annotate
(
Count
(
'assets'
))
return
queryset
def
perform_create
(
self
,
serializer
):
child_key
=
Node
.
root
()
.
get_next_child_key
()
serializer
.
validated_data
[
"key"
]
=
child_key
serializer
.
save
()
def
update
(
self
,
request
,
*
args
,
**
kwargs
):
node
=
self
.
get_object
()
if
node
.
is_root
():
node_value
=
node
.
value
post_value
=
request
.
data
.
get
(
'value'
)
if
node_value
!=
post_value
:
return
Response
(
{
"msg"
:
_
(
"You cant update the root node name"
)},
status
=
400
)
return
super
()
.
update
(
request
,
*
args
,
**
kwargs
)
class
NodeChildrenApi
(
mixins
.
ListModelMixin
,
generics
.
CreateAPIView
):
queryset
=
Node
.
objects
.
all
()
...
...
@@ -108,9 +116,9 @@ class NodeChildrenApi(mixins.ListModelMixin, generics.CreateAPIView):
queryset
.
append
(
node
)
if
query_all
:
children
=
node
.
get_all_children
()
.
annotate
(
Count
(
"assets"
))
children
=
node
.
get_all_children
()
else
:
children
=
node
.
get_children
()
.
annotate
(
Count
(
"assets"
))
children
=
node
.
get_children
()
queryset
.
extend
(
list
(
children
))
if
query_assets
:
...
...
apps/assets/models/node.py
View file @
ae564ed0
...
...
@@ -199,6 +199,11 @@ class Node(OrgModelMixin):
else
:
return
cls
.
create_root_node
()
@classmethod
def
default_node
(
cls
):
defaults
=
{
'value'
:
'Default'
}
return
cls
.
objects
.
get_or_create
(
defaults
=
defaults
,
key
=
'0'
)
@classmethod
def
generate_fake
(
cls
,
count
=
100
):
import
random
...
...
apps/assets/serializers/node.py
View file @
ae564ed0
...
...
@@ -68,7 +68,7 @@ class NodeSerializer(serializers.ModelSerializer):
@staticmethod
def
get_assets_amount
(
obj
):
return
obj
.
assets__count
if
hasattr
(
obj
,
'assets__count'
)
else
0
return
obj
.
get_all_assets
()
.
count
()
@staticmethod
def
get_tree_id
(
obj
):
...
...
apps/assets/templates/assets/asset_list.html
View file @
ae564ed0
...
...
@@ -288,7 +288,9 @@ function onRename(event, treeId, treeNode, isCancel){
APIUpdateAttr
({
url
:
url
,
body
:
JSON
.
stringify
(
data
),
method
:
"PATCH"
method
:
"PATCH"
,
success_message
:
"{% trans 'Rename success' %}"
,
fail_message
:
"{% trans 'Rename failed, do not change the root node name' %}"
})
}
...
...
apps/assets/views/asset.py
View file @
ae564ed0
...
...
@@ -8,7 +8,6 @@ import codecs
import
chardet
from
io
import
StringIO
from
django.conf
import
settings
from
django.db
import
transaction
from
django.utils.translation
import
ugettext_lazy
as
_
from
django.views.generic
import
TemplateView
,
ListView
,
View
...
...
@@ -25,11 +24,12 @@ from django.shortcuts import redirect
from
django.contrib.messages.views
import
SuccessMessageMixin
from
common.mixins
import
JSONResponseMixin
from
common.utils
import
get_object_or_none
,
get_logger
,
is_uuid
from
common.utils
import
get_object_or_none
,
get_logger
from
common.permissions
import
AdminUserRequiredMixin
from
common.const
import
create_success_msg
,
update_success_msg
from
orgs.utils
import
current_org
from
..
import
forms
from
..models
import
Asset
,
AdminUser
,
SystemUser
,
Label
,
Node
,
Domain
from
common.permissions
import
AdminUserRequiredMixin
__all__
=
[
...
...
@@ -44,6 +44,9 @@ 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
()
context
=
{
'app'
:
_
(
'Assets'
),
...
...
apps/i18n/zh/LC_MESSAGES/django.mo
View file @
ae564ed0
No preview for this file type
apps/i18n/zh/LC_MESSAGES/django.po
View file @
ae564ed0
This diff is collapsed.
Click to expand it.
apps/jumpserver/settings.py
View file @
ae564ed0
...
...
@@ -261,10 +261,10 @@ LOGGING = {
'handlers'
:
[
'console'
,
'file'
],
'level'
:
"INFO"
,
},
'django.db'
:
{
'handlers'
:
[
'console'
,
'file'
],
'level'
:
'DEBUG'
}
#
'django.db': {
#
'handlers': ['console', 'file'],
#
'level': 'DEBUG'
#
}
}
}
...
...
@@ -322,7 +322,7 @@ REST_FRAMEWORK = {
'common.permissions.IsOrgAdmin'
,
),
'DEFAULT_AUTHENTICATION_CLASSES'
:
(
'rest_framework.authentication.BasicAuthentication'
,
#
'rest_framework.authentication.BasicAuthentication',
'users.authentication.AccessKeyAuthentication'
,
'users.authentication.AccessTokenAuthentication'
,
'users.authentication.PrivateTokenAuthentication'
,
...
...
apps/perms/utils.py
View file @
ae564ed0
...
...
@@ -139,8 +139,6 @@ class AssetPermissionUtil:
for
node
,
system_users
in
nodes
.
items
():
_assets
=
node
.
get_all_assets
()
.
valid
()
.
prefetch_related
(
'nodes'
)
for
asset
in
_assets
:
if
isinstance
(
asset
,
Node
):
print
(
_assets
)
assets
[
asset
]
.
update
(
system_users
)
self
.
_assets
=
assets
return
self
.
_assets
...
...
apps/terminal/api.py
View file @
ae564ed0
...
...
@@ -243,7 +243,6 @@ class CommandViewSet(viewsets.ViewSet):
def
create
(
self
,
request
,
*
args
,
**
kwargs
):
serializer
=
self
.
serializer_class
(
data
=
request
.
data
,
many
=
True
)
if
serializer
.
is_valid
():
print
(
serializer
.
validated_data
)
ok
=
self
.
command_store
.
bulk_save
(
serializer
.
validated_data
)
if
ok
:
return
Response
(
"ok"
,
status
=
201
)
...
...
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