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
fb9e2ac9
Commit
fb9e2ac9
authored
Nov 06, 2019
by
ibuler
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[Update] 修改用户和用户组关系发生变化时,刷新权限
parent
ed5a5704
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
13 additions
and
9 deletions
+13
-9
signals_handler.py
apps/perms/signals_handler.py
+0
-7
signals_handler.py
apps/users/signals_handler.py
+13
-2
No files found.
apps/perms/signals_handler.py
View file @
fb9e2ac9
...
@@ -11,13 +11,6 @@ from .utils.asset_permission import AssetPermissionUtilV2
...
@@ -11,13 +11,6 @@ from .utils.asset_permission import AssetPermissionUtilV2
logger
=
get_logger
(
__file__
)
logger
=
get_logger
(
__file__
)
permission_m2m_senders
=
(
AssetPermission
.
nodes
.
through
,
AssetPermission
.
assets
.
through
,
AssetPermission
.
users
.
through
,
AssetPermission
.
user_groups
.
through
,
)
@receiver
([
post_save
,
post_delete
],
sender
=
AssetPermission
)
@receiver
([
post_save
,
post_delete
],
sender
=
AssetPermission
)
@on_transaction_commit
@on_transaction_commit
...
...
apps/users/signals_handler.py
View file @
fb9e2ac9
...
@@ -2,11 +2,11 @@
...
@@ -2,11 +2,11 @@
#
#
from
django.dispatch
import
receiver
from
django.dispatch
import
receiver
# from django.db.models.signals import post_save
from
django.db.models.signals
import
post_save
,
m2m_changed
from
common.utils
import
get_logger
from
common.utils
import
get_logger
from
.signals
import
post_user_create
from
.signals
import
post_user_create
#
from .models import User
from
.models
import
User
logger
=
get_logger
(
__file__
)
logger
=
get_logger
(
__file__
)
...
@@ -28,3 +28,14 @@ def on_user_create(sender, user=None, **kwargs):
...
@@ -28,3 +28,14 @@ def on_user_create(sender, user=None, **kwargs):
logger
.
info
(
" - Sending welcome mail ..."
.
format
(
user
.
name
))
logger
.
info
(
" - Sending welcome mail ..."
.
format
(
user
.
name
))
if
user
.
email
:
if
user
.
email
:
send_user_created_mail
(
user
)
send_user_created_mail
(
user
)
@receiver
(
m2m_changed
,
sender
=
User
.
groups
.
through
)
def
on_user_groups_change
(
sender
,
instance
=
None
,
action
=
''
,
**
kwargs
):
"""
资产节点发生变化时,刷新节点
"""
if
action
.
startswith
(
'post'
):
logger
.
debug
(
"User group member change signal recv: {}"
.
format
(
instance
))
from
perms.utils
import
AssetPermissionUtilV2
AssetPermissionUtilV2
.
expire_all_user_tree_cache
()
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