Skip to content

Commit

Permalink
Merge branch 'Test'
Browse files Browse the repository at this point in the history
  • Loading branch information
Pooya-Oladazimi committed Jan 13, 2023
2 parents 13f8463 + a1b63d5 commit 49f5d02
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
6 changes: 4 additions & 2 deletions ckanext/multiuploader/controllers.py
Original file line number Diff line number Diff line change
Expand Up @@ -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" )
Expand Down
7 changes: 6 additions & 1 deletion ckanext/multiuploader/public/statics/multi_uploader.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
Expand Down Expand Up @@ -301,11 +301,16 @@ function cancelAlreadyUploaded(){
$('#upload-progress-modal-close').hide();
$('#upload-cancel').hide();
}
let filenames = [];
for(let i=0; i<fileList.length; i++){
filenames.push(fileList[i].name);
}
already_uploaded_count = 0;
uploadPercent = 0;
var formdata = new FormData();
let dest_url = $('#cancel_upload_url').val();
formdata.set('pck_id', $('#pck_id').val());
formdata.set('filenames', filenames);
var req = new XMLHttpRequest();
req.onreadystatechange = function() {
if (req.readyState == XMLHttpRequest.DONE && req.status === 200) {
Expand Down

0 comments on commit 49f5d02

Please sign in to comment.