mirror of
https://github.com/jumpserver/jumpserver.git
synced 2025-09-07 02:10:23 +00:00
Dev beta (#3167)
* [Update] 添加loading * [Update] 修改避免游离资产 * [Update] 修改nodes * [Update] 修改支持未分组
This commit is contained in:
@@ -15,25 +15,23 @@ logger = get_logger(__file__)
|
||||
@on_transaction_commit
|
||||
def on_permission_created(sender, instance=None, created=False, **kwargs):
|
||||
pass
|
||||
# AssetPermissionUtil.expire_all_cache()
|
||||
|
||||
|
||||
@receiver(post_save, sender=AssetPermission)
|
||||
def on_permission_update(sender, **kwargs):
|
||||
pass
|
||||
# AssetPermissionUtil.expire_all_cache()
|
||||
|
||||
|
||||
@receiver(post_delete, sender=AssetPermission)
|
||||
def on_permission_delete(sender, **kwargs):
|
||||
pass
|
||||
# AssetPermissionUtil.expire_all_cache()
|
||||
|
||||
|
||||
@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':
|
||||
def on_permission_nodes_changed(sender, instance=None, action='', **kwargs):
|
||||
if action != 'post_add':
|
||||
return
|
||||
if isinstance(instance, AssetPermission):
|
||||
logger.debug("Asset permission nodes change signal received")
|
||||
nodes = kwargs['model'].objects.filter(pk__in=kwargs['pk_set'])
|
||||
system_users = instance.system_users.all()
|
||||
@@ -42,9 +40,10 @@ 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':
|
||||
def on_permission_assets_changed(sender, instance=None, action='', **kwargs):
|
||||
if action != 'post_add':
|
||||
return
|
||||
if isinstance(instance, AssetPermission):
|
||||
logger.debug("Asset permission assets change signal received")
|
||||
assets = kwargs['model'].objects.filter(pk__in=kwargs['pk_set'])
|
||||
system_users = instance.system_users.all()
|
||||
@@ -53,13 +52,15 @@ 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")
|
||||
def on_permission_system_users_changed(sender, instance=None, action='', **kwargs):
|
||||
if action != 'post_add':
|
||||
return
|
||||
if isinstance(instance, AssetPermission):
|
||||
system_users = kwargs['model'].objects.filter(pk__in=kwargs['pk_set'])
|
||||
logger.debug("Asset permission system_users change signal received")
|
||||
assets = instance.assets.all()
|
||||
nodes = instance.nodes.all()
|
||||
for system_user in system_users:
|
||||
system_user.nodes.add(*tuple(nodes))
|
||||
system_user.assets.add(*tuple(assets))
|
||||
|
||||
|
Reference in New Issue
Block a user