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
e59b95e9
Commit
e59b95e9
authored
Aug 13, 2018
by
ibuler
Browse files
Options
Browse Files
Download
Plain Diff
Merge remote-tracking branch 'github/dev' into dev
parents
3f049440
bb639415
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
14 changed files
with
38 additions
and
21 deletions
+38
-21
node.py
apps/assets/api/node.py
+14
-6
node.py
apps/assets/models/node.py
+5
-0
asset.py
apps/assets/serializers/asset.py
+1
-1
node.py
apps/assets/serializers/node.py
+1
-1
asset_list.html
apps/assets/templates/assets/asset_list.html
+6
-3
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
+1
-0
api.py
apps/perms/api.py
+0
-1
utils.py
apps/perms/utils.py
+0
-2
api.py
apps/terminal/api.py
+0
-1
serializers.py
apps/users/serializers.py
+2
-1
requirements.txt
requirements/requirements.txt
+2
-2
No files found.
apps/assets/api/node.py
View file @
e59b95e9
...
@@ -43,15 +43,23 @@ class NodeViewSet(viewsets.ModelViewSet):
...
@@ -43,15 +43,23 @@ class NodeViewSet(viewsets.ModelViewSet):
permission_classes
=
(
IsOrgAdmin
,)
permission_classes
=
(
IsOrgAdmin
,)
serializer_class
=
serializers
.
NodeSerializer
serializer_class
=
serializers
.
NodeSerializer
def
get_queryset
(
self
):
queryset
=
super
()
.
get_queryset
()
.
annotate
(
Count
(
'assets'
))
return
queryset
def
perform_create
(
self
,
serializer
):
def
perform_create
(
self
,
serializer
):
child_key
=
Node
.
root
()
.
get_next_child_key
()
child_key
=
Node
.
root
()
.
get_next_child_key
()
serializer
.
validated_data
[
"key"
]
=
child_key
serializer
.
validated_data
[
"key"
]
=
child_key
serializer
.
save
()
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
):
class
NodeChildrenApi
(
mixins
.
ListModelMixin
,
generics
.
CreateAPIView
):
queryset
=
Node
.
objects
.
all
()
queryset
=
Node
.
objects
.
all
()
...
@@ -108,9 +116,9 @@ class NodeChildrenApi(mixins.ListModelMixin, generics.CreateAPIView):
...
@@ -108,9 +116,9 @@ class NodeChildrenApi(mixins.ListModelMixin, generics.CreateAPIView):
queryset
.
append
(
node
)
queryset
.
append
(
node
)
if
query_all
:
if
query_all
:
children
=
node
.
get_all_children
()
.
annotate
(
Count
(
"assets"
))
children
=
node
.
get_all_children
()
else
:
else
:
children
=
node
.
get_children
()
.
annotate
(
Count
(
"assets"
))
children
=
node
.
get_children
()
queryset
.
extend
(
list
(
children
))
queryset
.
extend
(
list
(
children
))
if
query_assets
:
if
query_assets
:
...
...
apps/assets/models/node.py
View file @
e59b95e9
...
@@ -199,6 +199,11 @@ class Node(OrgModelMixin):
...
@@ -199,6 +199,11 @@ class Node(OrgModelMixin):
else
:
else
:
return
cls
.
create_root_node
()
return
cls
.
create_root_node
()
@classmethod
def
default_node
(
cls
):
defaults
=
{
'value'
:
'Default'
}
return
cls
.
objects
.
get_or_create
(
defaults
=
defaults
,
key
=
'0'
)
@classmethod
@classmethod
def
generate_fake
(
cls
,
count
=
100
):
def
generate_fake
(
cls
,
count
=
100
):
import
random
import
random
...
...
apps/assets/serializers/asset.py
View file @
e59b95e9
...
@@ -20,7 +20,7 @@ class AssetSerializer(BulkSerializerMixin, serializers.ModelSerializer):
...
@@ -20,7 +20,7 @@ class AssetSerializer(BulkSerializerMixin, serializers.ModelSerializer):
model
=
Asset
model
=
Asset
list_serializer_class
=
BulkListSerializer
list_serializer_class
=
BulkListSerializer
fields
=
'__all__'
fields
=
'__all__'
# validators = [] # If not set to [], partial bulk update will be error
validators
=
[]
def
get_field_names
(
self
,
declared_fields
,
info
):
def
get_field_names
(
self
,
declared_fields
,
info
):
fields
=
super
()
.
get_field_names
(
declared_fields
,
info
)
fields
=
super
()
.
get_field_names
(
declared_fields
,
info
)
...
...
apps/assets/serializers/node.py
View file @
e59b95e9
...
@@ -68,7 +68,7 @@ class NodeSerializer(serializers.ModelSerializer):
...
@@ -68,7 +68,7 @@ class NodeSerializer(serializers.ModelSerializer):
@staticmethod
@staticmethod
def
get_assets_amount
(
obj
):
def
get_assets_amount
(
obj
):
return
obj
.
assets__count
if
hasattr
(
obj
,
'assets__count'
)
else
0
return
obj
.
get_all_assets
()
.
count
()
@staticmethod
@staticmethod
def
get_tree_id
(
obj
):
def
get_tree_id
(
obj
):
...
...
apps/assets/templates/assets/asset_list.html
View file @
e59b95e9
...
@@ -194,9 +194,10 @@ function addTreeNode() {
...
@@ -194,9 +194,10 @@ function addTreeNode() {
$
.
post
(
url
,
{},
function
(
data
,
status
){
$
.
post
(
url
,
{},
function
(
data
,
status
){
if
(
status
===
"success"
)
{
if
(
status
===
"success"
)
{
var
newNode
=
{
var
newNode
=
{
id
:
data
[
"key"
],
name
:
data
[
"value"
],
name
:
data
[
"value"
],
id
:
data
[
"id"
],
node_
id
:
data
[
"id"
],
pId
:
parentNode
.
node_
id
pId
:
parentNode
.
id
};
};
newNode
.
checked
=
zTree
.
getSelectedNodes
()[
0
].
checked
;
newNode
.
checked
=
zTree
.
getSelectedNodes
()[
0
].
checked
;
zTree
.
addNodes
(
parentNode
,
0
,
newNode
);
zTree
.
addNodes
(
parentNode
,
0
,
newNode
);
...
@@ -287,7 +288,9 @@ function onRename(event, treeId, treeNode, isCancel){
...
@@ -287,7 +288,9 @@ function onRename(event, treeId, treeNode, isCancel){
APIUpdateAttr
({
APIUpdateAttr
({
url
:
url
,
url
:
url
,
body
:
JSON
.
stringify
(
data
),
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 @
e59b95e9
...
@@ -8,7 +8,6 @@ import codecs
...
@@ -8,7 +8,6 @@ import codecs
import
chardet
import
chardet
from
io
import
StringIO
from
io
import
StringIO
from
django.conf
import
settings
from
django.db
import
transaction
from
django.db
import
transaction
from
django.utils.translation
import
ugettext_lazy
as
_
from
django.utils.translation
import
ugettext_lazy
as
_
from
django.views.generic
import
TemplateView
,
ListView
,
View
from
django.views.generic
import
TemplateView
,
ListView
,
View
...
@@ -25,11 +24,12 @@ from django.shortcuts import redirect
...
@@ -25,11 +24,12 @@ from django.shortcuts import redirect
from
django.contrib.messages.views
import
SuccessMessageMixin
from
django.contrib.messages.views
import
SuccessMessageMixin
from
common.mixins
import
JSONResponseMixin
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
common.const
import
create_success_msg
,
update_success_msg
from
orgs.utils
import
current_org
from
..
import
forms
from
..
import
forms
from
..models
import
Asset
,
AdminUser
,
SystemUser
,
Label
,
Node
,
Domain
from
..models
import
Asset
,
AdminUser
,
SystemUser
,
Label
,
Node
,
Domain
from
common.permissions
import
AdminUserRequiredMixin
__all__
=
[
__all__
=
[
...
@@ -44,6 +44,9 @@ class AssetListView(AdminUserRequiredMixin, TemplateView):
...
@@ -44,6 +44,9 @@ class AssetListView(AdminUserRequiredMixin, TemplateView):
template_name
=
'assets/asset_list.html'
template_name
=
'assets/asset_list.html'
def
get_context_data
(
self
,
**
kwargs
):
def
get_context_data
(
self
,
**
kwargs
):
if
current_org
.
is_default
():
Node
.
default_node
()
else
:
Node
.
root
()
Node
.
root
()
context
=
{
context
=
{
'app'
:
_
(
'Assets'
),
'app'
:
_
(
'Assets'
),
...
...
apps/i18n/zh/LC_MESSAGES/django.mo
View file @
e59b95e9
No preview for this file type
apps/i18n/zh/LC_MESSAGES/django.po
View file @
e59b95e9
This diff is collapsed.
Click to expand it.
apps/jumpserver/settings.py
View file @
e59b95e9
...
@@ -322,6 +322,7 @@ REST_FRAMEWORK = {
...
@@ -322,6 +322,7 @@ REST_FRAMEWORK = {
'common.permissions.IsOrgAdmin'
,
'common.permissions.IsOrgAdmin'
,
),
),
'DEFAULT_AUTHENTICATION_CLASSES'
:
(
'DEFAULT_AUTHENTICATION_CLASSES'
:
(
# 'rest_framework.authentication.BasicAuthentication',
'users.authentication.AccessKeyAuthentication'
,
'users.authentication.AccessKeyAuthentication'
,
'users.authentication.AccessTokenAuthentication'
,
'users.authentication.AccessTokenAuthentication'
,
'users.authentication.PrivateTokenAuthentication'
,
'users.authentication.PrivateTokenAuthentication'
,
...
...
apps/perms/api.py
View file @
e59b95e9
...
@@ -5,7 +5,6 @@ from django.shortcuts import get_object_or_404
...
@@ -5,7 +5,6 @@ from django.shortcuts import get_object_or_404
from
rest_framework.views
import
APIView
,
Response
from
rest_framework.views
import
APIView
,
Response
from
rest_framework.generics
import
ListAPIView
,
get_object_or_404
,
RetrieveUpdateAPIView
from
rest_framework.generics
import
ListAPIView
,
get_object_or_404
,
RetrieveUpdateAPIView
from
rest_framework
import
viewsets
from
rest_framework
import
viewsets
from
rest_framework.pagination
import
LimitOffsetPagination
from
common.utils
import
set_or_append_attr_bulk
,
get_object_or_none
from
common.utils
import
set_or_append_attr_bulk
,
get_object_or_none
from
common.permissions
import
IsValidUser
,
IsOrgAdmin
,
IsOrgAdminOrAppUser
from
common.permissions
import
IsValidUser
,
IsOrgAdmin
,
IsOrgAdminOrAppUser
...
...
apps/perms/utils.py
View file @
e59b95e9
...
@@ -139,8 +139,6 @@ class AssetPermissionUtil:
...
@@ -139,8 +139,6 @@ class AssetPermissionUtil:
for
node
,
system_users
in
nodes
.
items
():
for
node
,
system_users
in
nodes
.
items
():
_assets
=
node
.
get_all_assets
()
.
valid
()
.
prefetch_related
(
'nodes'
)
_assets
=
node
.
get_all_assets
()
.
valid
()
.
prefetch_related
(
'nodes'
)
for
asset
in
_assets
:
for
asset
in
_assets
:
if
isinstance
(
asset
,
Node
):
print
(
_assets
)
assets
[
asset
]
.
update
(
system_users
)
assets
[
asset
]
.
update
(
system_users
)
self
.
_assets
=
assets
self
.
_assets
=
assets
return
self
.
_assets
return
self
.
_assets
...
...
apps/terminal/api.py
View file @
e59b95e9
...
@@ -243,7 +243,6 @@ class CommandViewSet(viewsets.ViewSet):
...
@@ -243,7 +243,6 @@ class CommandViewSet(viewsets.ViewSet):
def
create
(
self
,
request
,
*
args
,
**
kwargs
):
def
create
(
self
,
request
,
*
args
,
**
kwargs
):
serializer
=
self
.
serializer_class
(
data
=
request
.
data
,
many
=
True
)
serializer
=
self
.
serializer_class
(
data
=
request
.
data
,
many
=
True
)
if
serializer
.
is_valid
():
if
serializer
.
is_valid
():
print
(
serializer
.
validated_data
)
ok
=
self
.
command_store
.
bulk_save
(
serializer
.
validated_data
)
ok
=
self
.
command_store
.
bulk_save
(
serializer
.
validated_data
)
if
ok
:
if
ok
:
return
Response
(
"ok"
,
status
=
201
)
return
Response
(
"ok"
,
status
=
201
)
...
...
apps/users/serializers.py
View file @
e59b95e9
...
@@ -23,6 +23,7 @@ class UserSerializer(BulkSerializerMixin, serializers.ModelSerializer):
...
@@ -23,6 +23,7 @@ class UserSerializer(BulkSerializerMixin, serializers.ModelSerializer):
'first_name'
,
'last_name'
,
'password'
,
'_private_key'
,
'first_name'
,
'last_name'
,
'password'
,
'_private_key'
,
'_public_key'
,
'_otp_secret_key'
,
'user_permissions'
'_public_key'
,
'_otp_secret_key'
,
'user_permissions'
]
]
# validators = []
def
get_field_names
(
self
,
declared_fields
,
info
):
def
get_field_names
(
self
,
declared_fields
,
info
):
fields
=
super
(
UserSerializer
,
self
)
.
get_field_names
(
declared_fields
,
info
)
fields
=
super
(
UserSerializer
,
self
)
.
get_field_names
(
declared_fields
,
info
)
...
@@ -71,7 +72,7 @@ class UserGroupSerializer(BulkSerializerMixin, serializers.ModelSerializer):
...
@@ -71,7 +72,7 @@ class UserGroupSerializer(BulkSerializerMixin, serializers.ModelSerializer):
class
UserGroupUpdateMemeberSerializer
(
serializers
.
ModelSerializer
):
class
UserGroupUpdateMemeberSerializer
(
serializers
.
ModelSerializer
):
users
=
serializers
.
PrimaryKeyRelatedField
(
many
=
True
,
queryset
=
User
.
objects
.
all
())
users
=
serializers
.
PrimaryKeyRelatedField
(
many
=
True
,
queryset
=
User
.
objects
.
all
())
class
Meta
:
class
Meta
:
model
=
UserGroup
model
=
UserGroup
...
...
requirements/requirements.txt
View file @
e59b95e9
...
@@ -14,11 +14,11 @@ coreapi==2.3.3
...
@@ -14,11 +14,11 @@ coreapi==2.3.3
coreschema==0.0.4
coreschema==0.0.4
cryptography==2.1.4
cryptography==2.1.4
decorator==4.1.2
decorator==4.1.2
Django==2.
0.7
Django==2.
1.0
django-auth-ldap==1.3.0
django-auth-ldap==1.3.0
django-bootstrap3==9.1.0
django-bootstrap3==9.1.0
django-celery-beat==1.1.1
django-celery-beat==1.1.1
django-filter==
1.1
.0
django-filter==
2.0
.0
django-formtools==2.1
django-formtools==2.1
django-ranged-response==0.2.0
django-ranged-response==0.2.0
django-redis-cache==1.7.1
django-redis-cache==1.7.1
...
...
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