Browse Source

fix: Asset perm calculate failed (#13530)

Co-authored-by: feng <1304903146@qq.com>
Co-authored-by: feng626 <57284900+feng626@users.noreply.github.com>
pull/13533/head
fit2bot 5 months ago committed by GitHub
parent
commit
7b4d3c44f8
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 2
      apps/assets/models/node.py
  2. 2
      apps/assets/utils/node.py
  3. 2
      apps/perms/utils/user_perm_tree.py

2
apps/assets/models/node.py

@ -356,7 +356,7 @@ class NodeAllAssetsMappingMixin:
node_ids_key = Node.objects.annotate(
char_id=output_as_string('id')
).values_list('char_id', 'key')
node_ids_key = [(str(uuid.UUID(node_id)), node_key) for node_id, node_key in node_ids_key]
node_id_ancestor_keys_mapping = {
node_id: cls.get_node_ancestor_keys(node_key, with_self=True)
for node_id, node_key in node_ids_key

2
apps/assets/utils/node.py

@ -1,6 +1,7 @@
# ~*~ coding: utf-8 ~*~
#
from collections import defaultdict
from uuid import UUID
from common.db.models import output_as_string
from common.struct import Stack
@ -133,6 +134,7 @@ class NodeAssetsUtil:
mapping = defaultdict(set)
for key, asset_id in nodes_assets:
asset_id = str(UUID(asset_id))
mapping[key].add(asset_id)
util = cls(nodes, mapping)

2
apps/perms/utils/user_perm_tree.py

@ -274,11 +274,13 @@ class UserPermTreeBuildUtil(object):
for key in self.perm_node_keys_for_granted:
asset_ids = PermNode.get_all_asset_ids_by_node_key(org_id, key)
nodekey_assetid_mapper[key].update(asset_ids)
for asset_id, node_id in self.direct_asset_id_node_id_pairs:
node_key = self.perm_nodes_id_key_mapper.get(str(node_id))
if not node_key:
continue
nodekey_assetid_mapper[node_key].add(asset_id)
util = NodeAssetsUtil(self.perm_nodes, nodekey_assetid_mapper)
util.generate()

Loading…
Cancel
Save