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
e5185ebd
Unverified
Commit
e5185ebd
authored
Jun 03, 2019
by
BaiJiangJie
Committed by
GitHub
Jun 03, 2019
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #2770 from jumpserver/dev
Dev
parents
35a0b42b
1ba93519
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
4 additions
and
0 deletions
+4
-0
signals_handler.py
apps/perms/signals_handler.py
+4
-0
No files found.
apps/perms/signals_handler.py
View file @
e5185ebd
...
...
@@ -24,6 +24,7 @@ def on_transaction_commit(func):
@receiver
(
post_save
,
sender
=
AssetPermission
,
dispatch_uid
=
"my_unique_identifier"
)
@on_transaction_commit
def
on_permission_created
(
sender
,
instance
=
None
,
created
=
False
,
**
kwargs
):
AssetPermissionUtil
.
expire_all_cache
()
actions
=
instance
.
actions
.
all
()
if
created
and
not
actions
:
default_action
=
Action
.
get_action_all
()
...
...
@@ -45,6 +46,7 @@ def on_permission_delete(sender, **kwargs):
@receiver
(
m2m_changed
,
sender
=
AssetPermission
.
nodes
.
through
)
def
on_permission_nodes_changed
(
sender
,
instance
=
None
,
**
kwargs
):
AssetPermissionUtil
.
expire_all_cache
()
if
isinstance
(
instance
,
AssetPermission
)
and
kwargs
[
'action'
]
==
'post_add'
:
logger
.
debug
(
"Asset permission nodes change signal received"
)
nodes
=
kwargs
[
'model'
]
.
objects
.
filter
(
pk__in
=
kwargs
[
'pk_set'
])
...
...
@@ -55,6 +57,7 @@ def on_permission_nodes_changed(sender, instance=None, **kwargs):
@receiver
(
m2m_changed
,
sender
=
AssetPermission
.
assets
.
through
)
def
on_permission_assets_changed
(
sender
,
instance
=
None
,
**
kwargs
):
AssetPermissionUtil
.
expire_all_cache
()
if
isinstance
(
instance
,
AssetPermission
)
and
kwargs
[
'action'
]
==
'post_add'
:
logger
.
debug
(
"Asset permission assets change signal received"
)
assets
=
kwargs
[
'model'
]
.
objects
.
filter
(
pk__in
=
kwargs
[
'pk_set'
])
...
...
@@ -65,6 +68,7 @@ def on_permission_assets_changed(sender, instance=None, **kwargs):
@receiver
(
m2m_changed
,
sender
=
AssetPermission
.
system_users
.
through
)
def
on_permission_system_users_changed
(
sender
,
instance
=
None
,
**
kwargs
):
AssetPermissionUtil
.
expire_all_cache
()
if
isinstance
(
instance
,
AssetPermission
)
and
kwargs
[
'action'
]
==
'post_add'
:
logger
.
debug
(
"Asset permission system_users change signal received"
)
system_users
=
kwargs
[
'model'
]
.
objects
.
filter
(
pk__in
=
kwargs
[
'pk_set'
])
...
...
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