From a1b63d52c5cf59664417b581078e6436e18802ce Mon Sep 17 00:00:00 2001 From: "pooya.oa" Date: Fri, 13 Jan 2023 16:31:08 +0100 Subject: [PATCH] fix the bug with cancel upload on backend --- ckanext/multiuploader/controllers.py | 6 ++++-- ckanext/multiuploader/public/statics/multi_uploader.js | 7 ++++++- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/ckanext/multiuploader/controllers.py b/ckanext/multiuploader/controllers.py index 22b4b37..effdce9 100755 --- a/ckanext/multiuploader/controllers.py +++ b/ckanext/multiuploader/controllers.py @@ -43,10 +43,12 @@ def upload_resources(): def delete_uploaded_resources(): package_name = request.form.get('pck_id') + filenames = request.form.get('filenames') if toolkit.g.user: package = toolkit.get_action('package_show')({}, {'name_or_id': package_name}) - package['resources'] = [] - toolkit.get_action('package_update')({},package) + for res in package['resources']: + if res['name'] in filenames: + toolkit.get_action('resource_delete')({}, {'id': res['id']}) return "True" else: return toolkit.abort(403, "You need to authenticate before accessing this function" ) diff --git a/ckanext/multiuploader/public/statics/multi_uploader.js b/ckanext/multiuploader/public/statics/multi_uploader.js index 9f4e3b4..114aad0 100755 --- a/ckanext/multiuploader/public/statics/multi_uploader.js +++ b/ckanext/multiuploader/public/statics/multi_uploader.js @@ -157,7 +157,7 @@ $(document).ready(function(){ show: true }); for(var i = 0; i < fileList.length; i++){ - // upload a file + // upload a file uploadFiles(fileList[i], sBtn, fileList.length); } } @@ -301,11 +301,16 @@ function cancelAlreadyUploaded(){ $('#upload-progress-modal-close').hide(); $('#upload-cancel').hide(); } + let filenames = []; + for(let i=0; i