From 001e85eea7c317b27c6a0ab167731241b9014ee2 Mon Sep 17 00:00:00 2001 From: j <0x006A@0x2620.org> Date: Sun, 28 Apr 2013 17:57:24 +0000 Subject: [PATCH] fix manage files to load again and handle upper case extensions --- pandora/item/utils.py | 4 ++-- static/js/pandora/filesDialog.js | 30 +++++++++++++-------------- static/js/pandora/uploadFileDialog.js | 16 ++++++++------ 3 files changed, 27 insertions(+), 23 deletions(-) diff --git a/pandora/item/utils.py b/pandora/item/utils.py index eb22963ee..ba8eb8901 100644 --- a/pandora/item/utils.py +++ b/pandora/item/utils.py @@ -68,8 +68,8 @@ def get_positions(ids, pos): for i in pos: try: positions[i] = ids.index(i) - except: - pass + except: + pass return positions def get_by_key(objects, key, value): diff --git a/static/js/pandora/filesDialog.js b/static/js/pandora/filesDialog.js index 1440bd7ff..10e88ad6e 100644 --- a/static/js/pandora/filesDialog.js +++ b/static/js/pandora/filesDialog.js @@ -186,16 +186,6 @@ pandora.ui.filesDialog = function() { } }), - $itemLabel = Ox.Label({ - textAlign: 'center', - title: 'No file selected', - width: getLabelWidth() - }) - .css({ - float: 'left', - margin: '4px' - }), - $closeButton = Ox.Button({ title: 'close', tooltip: 'Close', @@ -293,6 +283,16 @@ pandora.ui.filesDialog = function() { orientation: 'horizontal' }), + $itemLabel = Ox.Label({ + textAlign: 'center', + title: 'No file selected', + width: getLabelWidth() + }) + .css({ + float: 'left', + margin: '4px' + }), + that = Ox.Dialog({ buttons: [ Ox.Button({ @@ -521,17 +521,17 @@ pandora.ui.filesDialog = function() { pandora.ui.uploadFileDialog(data.files[0], function(file) { Ox.Request.clearCache('findFiles'); pandora.api.findFiles({ - ids: [file.id], - query: $list.options.query, - sort: $list.options.sort, + positions: [file.id], + query: $list.options('query'), + sort: $list.options('sort'), }, function(data) { $list.bindEventOnce({ load: function() { - list.options({selected: [file.id]}); + $list.options({selected: [file.id]}); // selectFile(file.id); } }); - if (data.positions[file.id] > -1) { + if (data.data.positions[file.id] > -1) { $list.reloadList(); } else { $list.options({ diff --git a/static/js/pandora/uploadFileDialog.js b/static/js/pandora/uploadFileDialog.js index d4a146ccb..2670f256b 100644 --- a/static/js/pandora/uploadFileDialog.js +++ b/static/js/pandora/uploadFileDialog.js @@ -7,6 +7,11 @@ pandora.ui.uploadFileDialog = function(file, callback) { extensions = ['gif', 'jpg', 'jpeg', 'pdf', 'png'], + filename = file.name.split('.').slice(0, -1).join('.') + '.' + + (extension == 'jpeg' ? 'jpg' : extension), + + id = pandora.user.username + ':' + filename, + upload, $errorDialog, @@ -40,7 +45,9 @@ pandora.ui.uploadFileDialog = function(file, callback) { if (title == 'Cancel Upload') { upload.abort(); } else if (title == 'Done') { - callback(); + callback({ + id: id + }); } } }) @@ -55,9 +62,7 @@ pandora.ui.uploadFileDialog = function(file, callback) { open: function() { upload = pandora.chunkupload({ data: { - filename: extension == 'jpeg' - ? file.name.split('.').slice(0, -1).join('.') + '.jpg' - : file.name + filename: filename }, file: file, url: '/api/upload/file/', @@ -93,11 +98,10 @@ pandora.ui.uploadFileDialog = function(file, callback) { range: [0, 1], sort: [{key: 'name', operator: '+'}] }, function(result) { - var id = pandora.user.name + ':' + file.name; if (result.data.items.length) { errorDialog( 'The file ' + id + ' already exists' + ( - file.name == result.data.items[0].id + filename == result.data.items[0].id ? '' : ' as ' + result.data.items[0].id ) + '.'