diff --git a/apps/assets/signal_handlers/asset.py b/apps/assets/signal_handlers/asset.py index 5aac26319..86e6a0a9a 100644 --- a/apps/assets/signal_handlers/asset.py +++ b/apps/assets/signal_handlers/asset.py @@ -103,6 +103,7 @@ def on_asset_nodes_add(instance, action, reverse, pk_set, **kwargs): # m2m_model.objects.bulk_create(to_create) # + RELATED_NODE_IDS = '_related_node_ids' diff --git a/apps/perms/apps.py b/apps/perms/apps.py index f9d1e6f42..432c194cd 100644 --- a/apps/perms/apps.py +++ b/apps/perms/apps.py @@ -10,5 +10,5 @@ class PermsConfig(AppConfig): def ready(self): super().ready() - # from . import signal_handlers + from . import signal_handlers from . import notifications diff --git a/apps/perms/models/perm_node.py b/apps/perms/models/perm_node.py index 438cd5b2d..1db0f2fe7 100644 --- a/apps/perms/models/perm_node.py +++ b/apps/perms/models/perm_node.py @@ -32,6 +32,9 @@ class UserAssetGrantedTreeNodeRelation(FamilyMixin, JMSOrgBaseModel): node_assets_amount = models.IntegerField(default=0) comment = '' + def __str__(self): + return f'{self.user}|{self.node}' + @property def key(self): return self.node_key diff --git a/apps/perms/signal_handlers/__init__.py b/apps/perms/signal_handlers/__init__.py index 6a8ef9467..02faddd04 100644 --- a/apps/perms/signal_handlers/__init__.py +++ b/apps/perms/signal_handlers/__init__.py @@ -1,2 +1,2 @@ -from . import asset_permission -from . import refresh_perms +from .asset_permission import * +from .refresh_perms import * diff --git a/apps/perms/utils/user_perm_tree.py b/apps/perms/utils/user_perm_tree.py index 7937f2c6f..8888a67e9 100644 --- a/apps/perms/utils/user_perm_tree.py +++ b/apps/perms/utils/user_perm_tree.py @@ -121,9 +121,8 @@ class UserPermTreeExpireUtil(_UserPermTreeCacheMixin): for org_id, perm_id in org_perm_ids: org_perms_mapper[org_id].add(perm_id) for org_id, perms_id in org_perms_mapper.items(): - org_ids = [org_id] user_ids = AssetPermission.get_all_users_for_perms(perm_ids, flat=True) - self.expire_perm_tree_for_users_orgs(user_ids, org_ids) + self.expire_perm_tree_for_users_orgs(user_ids, [org_id]) def expire_perm_tree_for_user_group(self, user_group): group_ids = [user_group.id] @@ -138,7 +137,7 @@ class UserPermTreeExpireUtil(_UserPermTreeCacheMixin): @on_transaction_commit def expire_perm_tree_for_users_orgs(self, user_ids, org_ids): org_ids = [str(oid) for oid in org_ids] - with self.client.pipline() as p: + with self.client.pipeline() as p: for uid in user_ids: cache_key = self.get_cache_key(uid) p.srem(cache_key, *org_ids) @@ -147,7 +146,7 @@ class UserPermTreeExpireUtil(_UserPermTreeCacheMixin): def expire_perm_tree_for_all_user(self): keys = self.client.keys(self.cache_key_all_user) - with self.client.pipline() as p: + with self.client.pipeline() as p: for k in keys: p.delete(k) p.execute()