diff --git a/apps/assets/templates/assets/asset_list.html b/apps/assets/templates/assets/asset_list.html index 3e1a8cfcd..79c34c043 100644 --- a/apps/assets/templates/assets/asset_list.html +++ b/apps/assets/templates/assets/asset_list.html @@ -451,10 +451,11 @@ $(document).ready(function(){ $.each(rows, function (index, obj) { assets.push(obj.id) }); + var _node_id = current_node ? current_node : null; $.ajax({ url: "{% url "assets:asset-export" %}", method: 'POST', - data: JSON.stringify({assets_id: assets, node_id: current_node.node_id}), + data: JSON.stringify({assets_id: assets, node_id: _node_id}), dataType: "json", success: function (data, textStatus) { window.open(data.redirect) diff --git a/apps/assets/views/asset.py b/apps/assets/views/asset.py index eb9972e94..c36ad9cc9 100644 --- a/apps/assets/views/asset.py +++ b/apps/assets/views/asset.py @@ -214,13 +214,13 @@ class AssetExportView(LoginRequiredMixin, View): def post(self, request, *args, **kwargs): try: assets_id = json.loads(request.body).get('assets_id', []) - assets_node_id = json.loads(request.body).get('node_id', None) + node_id = json.loads(request.body).get('node_id', None) except ValueError: return HttpResponse('Json object not valid', status=400) - if not assets_id and assets_node_id: - assets_node = get_object_or_none(Node, id=assets_node_id) - assets = assets_node.get_all_assets() + if not assets_id: + node = get_object_or_none(Node, id=node_id) if node_id else Node.root() + assets = node.get_all_assets() for asset in assets: assets_id.append(asset.id)