fix(assets): node asset 关系发生变化是,关联系统用户引起的问题

pull/4302/head
ibuler 2020-07-10 16:31:12 +08:00 committed by BaiJiangJie
parent c0cd8878dc
commit 437df9a533
1 changed files with 3 additions and 1 deletions

View File

@ -185,7 +185,9 @@ def on_asset_nodes_add(sender, instance=None, action='', model=None, pk_set=None
system_users_assets = defaultdict(set)
for system_user in system_users:
system_users_assets[system_user].update(set(assets))
assets_has_set = system_user.assets.all().filter(id__in=assets).values_list('id', flat=True)
assets_remain = set(assets) - set(assets_has_set)
system_users_assets[system_user].update(assets_remain)
for system_user, _assets in system_users_assets.items():
system_user.assets.add(*tuple(_assets))