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
bf40aa8d
Commit
bf40aa8d
authored
Nov 19, 2019
by
ibuler
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[Update] 修改user list api
parent
0c349f93
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
32 additions
and
19 deletions
+32
-19
models.py
apps/common/mixins/models.py
+12
-0
models.py
apps/orgs/models.py
+16
-4
jumpserver.js
apps/static/js/jumpserver.js
+2
-0
user.py
apps/users/models/user.py
+2
-1
user.py
apps/users/serializers/user.py
+0
-14
No files found.
apps/common/mixins/models.py
View file @
bf40aa8d
...
...
@@ -53,3 +53,15 @@ class CommonModelMixin(models.Model):
class
Meta
:
abstract
=
True
class
DebugQueryManager
(
models
.
Manager
):
def
get_queryset
(
self
):
import
traceback
lines
=
traceback
.
format_stack
()
print
(
">>>>>>>>>>>>>>>>>>>>>>>>>>>>"
)
for
line
in
lines
[
-
10
:
-
1
]:
print
(
line
)
print
(
"<<<<<<<<<<<<<<<<<<<<<<<<<<<<"
)
queryset
=
super
()
.
get_queryset
()
return
queryset
apps/orgs/models.py
View file @
bf40aa8d
...
...
@@ -4,7 +4,7 @@ from django.conf import settings
from
django.db
import
models
from
django.utils.translation
import
ugettext_lazy
as
_
from
common.utils
import
is_uuid
from
common.utils
import
is_uuid
,
lazyproperty
class
Organization
(
models
.
Model
):
...
...
@@ -72,7 +72,8 @@ class Organization(models.Model):
org
=
cls
.
default
()
if
default
else
None
return
org
def
get_org_users
(
self
):
@lazyproperty
def
org_users
(
self
):
from
users.models
import
User
if
self
.
is_real
():
return
self
.
users
.
all
()
...
...
@@ -81,18 +82,29 @@ class Organization(models.Model):
users
=
users
.
filter
(
related_user_orgs__isnull
=
True
)
return
users
def
get_org_admins
(
self
):
def
get_org_users
(
self
):
return
self
.
org_users
@lazyproperty
def
org_admins
(
self
):
from
users.models
import
User
if
self
.
is_real
():
return
self
.
admins
.
all
()
return
User
.
objects
.
filter
(
role
=
User
.
ROLE_ADMIN
)
def
get_org_auditors
(
self
):
def
get_org_admins
(
self
):
return
self
.
org_admins
@lazyproperty
def
org_auditors
(
self
):
from
users.models
import
User
if
self
.
is_real
():
return
self
.
auditors
.
all
()
return
User
.
objects
.
filter
(
role
=
User
.
ROLE_AUDITOR
)
def
get_org_auditors
(
self
):
return
self
.
org_auditors
def
get_org_members
(
self
,
exclude
=
()):
from
users.models
import
User
members
=
User
.
objects
.
none
()
...
...
apps/static/js/jumpserver.js
View file @
bf40aa8d
...
...
@@ -299,6 +299,8 @@ function requestApi(props) {
msg
=
jqXHR
.
responseJSON
.
error
}
else
if
(
jqXHR
.
responseJSON
.
msg
)
{
msg
=
jqXHR
.
responseJSON
.
msg
}
else
if
(
jqXHR
.
responseJSON
.
detail
)
{
msg
=
jqXHR
.
responseJSON
.
detail
}
}
if
(
msg
===
""
)
{
...
...
apps/users/models/user.py
View file @
bf40aa8d
...
...
@@ -404,7 +404,8 @@ class MFAMixin:
def
mfa_enabled_but_not_set
(
self
):
if
self
.
mfa_enabled
and
\
self
.
mfa_is_otp
()
and
not
self
.
otp_secret_key
:
self
.
mfa_is_otp
()
and
\
not
self
.
otp_secret_key
:
return
True
return
False
...
...
apps/users/serializers/user.py
View file @
bf40aa8d
...
...
@@ -18,9 +18,6 @@ __all__ = [
class
UserSerializer
(
BulkSerializerMixin
,
serializers
.
ModelSerializer
):
can_update
=
serializers
.
SerializerMethodField
()
can_delete
=
serializers
.
SerializerMethodField
()
class
Meta
:
model
=
User
list_serializer_class
=
AdaptedBulkListSerializer
...
...
@@ -31,7 +28,6 @@ class UserSerializer(BulkSerializerMixin, serializers.ModelSerializer):
'comment'
,
'source'
,
'source_display'
,
'is_valid'
,
'is_expired'
,
'is_active'
,
'created_by'
,
'is_first_login'
,
'date_password_last_updated'
,
'date_expired'
,
'avatar_url'
,
'can_update'
,
'can_delete'
,
]
extra_kwargs
=
{
'password'
:
{
'write_only'
:
True
,
'required'
:
False
,
'allow_null'
:
True
,
'allow_blank'
:
True
},
...
...
@@ -48,16 +44,6 @@ class UserSerializer(BulkSerializerMixin, serializers.ModelSerializer):
'can_delete'
:
{
'read_only'
:
True
},
}
def
get_can_update
(
self
,
obj
):
return
CanUpdateDeleteUser
.
has_update_object_permission
(
self
.
context
[
'request'
],
self
.
context
[
'view'
],
obj
)
def
get_can_delete
(
self
,
obj
):
return
CanUpdateDeleteUser
.
has_delete_object_permission
(
self
.
context
[
'request'
],
self
.
context
[
'view'
],
obj
)
def
validate_role
(
self
,
value
):
request
=
self
.
context
.
get
(
'request'
)
if
not
request
.
user
.
is_superuser
and
value
!=
User
.
ROLE_USER
:
...
...
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