Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
l y
Jumpserver
Commits
4cf5573c
Commit
4cf5573c
authored
4 years ago
by
xinwen
Committed by
老广
4 years ago
Browse files
Options
Download
Email Patches
Plain Diff
fix(users): 修复用户与用户组关系变化时没触发信号
parent
962ea67b
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
apps/users/api/relation.py
+6
-6
apps/users/api/relation.py
with
6 additions
and
6 deletions
+6
-6
apps/users/api/relation.py
+
6
-
6
View file @
4cf5573c
# -*- coding: utf-8 -*-
#
from
rest_framework_bulk
import
BulkModelViewSet
from
django.db.models
import
F
from
common.drf.api
import
JMSBulkRelationModelViewSet
from
common.permissions
import
IsOrgAdmin
from
..
import
serializers
from
..models
import
User
...
...
@@ -11,17 +11,17 @@ from ..models import User
__all__
=
[
'UserUserGroupRelationViewSet'
]
class
UserUserGroupRelationViewSet
(
BulkModelViewSet
):
class
UserUserGroupRelationViewSet
(
JMS
Bulk
Relation
ModelViewSet
):
filter_fields
=
(
'user'
,
'usergroup'
)
search_fields
=
filter_fields
serializer_class
=
serializers
.
UserUserGroupRelationSerializer
permission_classes
=
(
IsOrgAdmin
,)
m2m_field
=
User
.
groups
.
field
def
get_queryset
(
self
):
queryset
=
User
.
groups
.
through
.
objects
.
all
()
\
.
annotate
(
user_display
=
F
(
'user__name'
))
\
.
annotate
(
usergroup_display
=
F
(
'usergroup__name'
))
return
queryset
return
super
().
get_queryset
().
annotate
(
user_display
=
F
(
'user__name'
),
usergroup_display
=
F
(
'usergroup__name'
)
)
def
allow_bulk_destroy
(
self
,
qs
,
filtered
):
if
filtered
.
count
()
!=
1
:
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Supports
Markdown
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
Menu
Projects
Groups
Snippets
Help