From ef02b1f83a7484030bef31b236359686fa8dbb9c Mon Sep 17 00:00:00 2001 From: ibuler Date: Tue, 25 Dec 2018 16:53:52 +0800 Subject: [PATCH] =?UTF-8?q?[Update]=20=E4=BF=AE=E6=94=B9bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/assets/signals_handler.py | 7 +++++-- apps/assets/templates/assets/asset_list.html | 8 ++++---- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/apps/assets/signals_handler.py b/apps/assets/signals_handler.py index 85156c60d..7d3b67f6c 100644 --- a/apps/assets/signals_handler.py +++ b/apps/assets/signals_handler.py @@ -74,8 +74,11 @@ def on_system_user_assets_change(sender, instance=None, **kwargs): @receiver(m2m_changed, sender=Asset.nodes.through) def on_asset_node_changed(sender, instance=None, **kwargs): - logger.debug("Asset node change signal received") + logger.debug("Asset nodes change signal received") if isinstance(instance, Asset): + if kwargs['action'] == 'pre_remove': + nodes = kwargs['model'].objects.filter(pk__in=kwargs['pk_set']) + Node.expire_nodes_assets_amount(nodes) if kwargs['action'] == 'post_add': nodes = kwargs['model'].objects.filter(pk__in=kwargs['pk_set']) Node.expire_nodes_assets_amount(nodes) @@ -91,7 +94,7 @@ def on_asset_node_changed(sender, instance=None, **kwargs): @receiver(m2m_changed, sender=Asset.nodes.through) def on_node_assets_changed(sender, instance=None, **kwargs): if isinstance(instance, Node): - logger.debug("Node assets change signal received") + logger.debug("Node assets change signal {} received".format(instance)) # 当节点和资产关系发生改变时,过期资产数量缓存 instance.expire_assets_amount() assets = kwargs['model'].objects.filter(pk__in=kwargs['pk_set']) diff --git a/apps/assets/templates/assets/asset_list.html b/apps/assets/templates/assets/asset_list.html index 2b4e3a9f8..c3c3a7ede 100644 --- a/apps/assets/templates/assets/asset_list.html +++ b/apps/assets/templates/assets/asset_list.html @@ -345,10 +345,10 @@ function beforeDrag() { function beforeDrop(treeId, treeNodes, targetNode, moveType) { var treeNodesNames = []; $.each(treeNodes, function (index, value) { - treeNodesNames.push(value.value); + treeNodesNames.push(value.name); }); - var msg = "你想移动节点: `" + treeNodesNames.join(",") + "` 到 `" + targetNode.value + "` 下吗?"; + var msg = "你想移动节点: `" + treeNodesNames.join(",") + "` 到 `" + targetNode.name + "` 下吗?"; return confirm(msg); } @@ -358,10 +358,10 @@ function onDrag(event, treeId, treeNodes) { function onDrop(event, treeId, treeNodes, targetNode, moveType) { var treeNodesIds = []; $.each(treeNodes, function (index, value) { - treeNodesIds.push(value.node_id); + treeNodesIds.push(value.meta.node.id); }); - var the_url = "{% url 'api-assets:node-add-children' pk=DEFAULT_PK %}".replace("{{ DEFAULT_PK }}", targetNode.node_id); + var the_url = "{% url 'api-assets:node-add-children' pk=DEFAULT_PK %}".replace("{{ DEFAULT_PK }}", targetNode.meta.node.id); var body = {nodes: treeNodesIds}; APIUpdateAttr({ url: the_url,