From 0be92069d46130aad675fa715184e9c209140ce9 Mon Sep 17 00:00:00 2001 From: Maciej Tronowski Date: Wed, 22 Apr 2015 16:19:55 +0200 Subject: [PATCH] gridftp: multiple fixes in handling and presenting errors --- filex/ftp.py | 7 ++-- filex/static/filex/filex.js | 15 ++++++- filex/templates/filex/source.html | 2 +- filex/templates/filex/upload.html | 70 ++++++++++++++++++--------------- filex/templates/filex/upload.js.html | 3 +- filex/utils.py | 33 ++++++++++------ filex/views.py | 45 +++++++++++++-------- qcg/templates/qcg/download_error.html | 8 ++++ qcg/views.py | 12 +++++- 9 files changed, 127 insertions(+), 68 deletions(-) create mode 100644 qcg/templates/qcg/download_error.html diff --git a/filex/ftp.py b/filex/ftp.py index 2c92f12..d83a55c 100644 --- a/filex/ftp.py +++ b/filex/ftp.py @@ -99,13 +99,14 @@ class FTPOperation: for attr in attrs.split(';'): try: key, value = attr.split('=', 1) - attrs_dict[key] = value except ValueError: - pass + key, value = attr, '' + + attrs_dict[key] = value yield { 'name': name, - 'type': 'directory' if attrs_dict['Type'] == 'dir' else 'file', + 'type': 'directory' if attrs_dict['Type'].endswith('dir') else 'file', 'size': int(attrs_dict['Size']), 'date': localtime(datetime.strptime(attrs_dict['Modify'], "%Y%m%d%H%M%S").replace(tzinfo=UTC())), } diff --git a/filex/static/filex/filex.js b/filex/static/filex/filex.js index eb71ee4..26bec82 100644 --- a/filex/static/filex/filex.js +++ b/filex/static/filex/filex.js @@ -284,9 +284,20 @@ $(function(){ $this.modal('hide'); $btn.button('reset'); - }, 'json').fail(function() { + }, 'json').fail(function(xhr) { console.error(arguments); - $btn.button('error'); + var error = (xhr.responseJSON || {}).error || undefined; + + if (typeof error === 'string') { + $('
', { + 'class': 'alert alert-danger', + html: ' ' + error + }).prependTo($this.find('.modal-body')); + $btn.button('reset'); + } + else { + $btn.button('error'); + } }); }); diff --git a/filex/templates/filex/source.html b/filex/templates/filex/source.html index ba88414..551ae51 100644 --- a/filex/templates/filex/source.html +++ b/filex/templates/filex/source.html @@ -75,7 +75,7 @@
diff --git a/filex/templates/filex/upload.html b/filex/templates/filex/upload.html index 346fc1d..b79d9c0 100644 --- a/filex/templates/filex/upload.html +++ b/filex/templates/filex/upload.html @@ -3,43 +3,51 @@

Lokalizacja: {{ host }}{{ sep }}{{ path }}

- - -
- -
Upuść pliki tutaj
- - +{% else %} + -