From 4b0aca483ca5f80c7a2ed48536e8430810a275bc Mon Sep 17 00:00:00 2001 From: Sigurd Gartmann Date: Sun, 8 Dec 2013 02:31:39 +0100 Subject: [PATCH 01/20] Ignore this until django 1.6 branch takes over --- .gitignore | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index e74c193..b0d4e48 100644 --- a/.gitignore +++ b/.gitignore @@ -7,7 +7,8 @@ db /share /env /venv +/django-jquery-file-upload *.log *.pot *.pyc -local_settings.py \ No newline at end of file +local_settings.py From 8d97d7fb8e63fab6c28857ae8471d3ac5195a5d4 Mon Sep 17 00:00:00 2001 From: Sigurd Gartmann Date: Sun, 8 Dec 2013 02:35:07 +0100 Subject: [PATCH 02/20] This works up until Django 1.6. A new branch exists for 1.6. --- requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index 67a04d6..23cb63a 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,2 +1,2 @@ -django +django<1.6 pillow From d5523a67d68528cfca39fa2a8d21ff34d94de4ed Mon Sep 17 00:00:00 2001 From: Sigurd Gartmann Date: Wed, 11 Dec 2013 19:43:06 +0100 Subject: [PATCH 03/20] Better handling of errors in backend. --- fileupload/views.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/fileupload/views.py b/fileupload/views.py index e863a20..98b339c 100644 --- a/fileupload/views.py +++ b/fileupload/views.py @@ -1,4 +1,7 @@ # encoding: utf-8 +import json + +from django.http import HttpResponse from django.views.generic import CreateView, DeleteView, ListView from .models import Picture from .response import JSONResponse, response_mimetype @@ -16,6 +19,9 @@ def form_valid(self, form): response['Content-Disposition'] = 'inline; filename=files.json' return response + def form_invalid(self, form): + data = json.dumps(form.errors) + return HttpResponse(content=data, status=400, content_type='application/json') class BasicVersionCreateView(PictureCreateView): template_name_suffix = '_basic_form' From 97c66173318c46985f7809df77edfea316bfdd53 Mon Sep 17 00:00:00 2001 From: Sigurd Gartmann Date: Wed, 11 Dec 2013 19:49:39 +0100 Subject: [PATCH 04/20] Show form validation errors from Django. --- fileupload/static/js/jquery.fileupload.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/fileupload/static/js/jquery.fileupload.js b/fileupload/static/js/jquery.fileupload.js index d048a94..3a1ec70 100644 --- a/fileupload/static/js/jquery.fileupload.js +++ b/fileupload/static/js/jquery.fileupload.js @@ -805,6 +805,9 @@ response.jqXHR = options.jqXHR = jqXHR; response.textStatus = options.textStatus = textStatus; response.errorThrown = options.errorThrown = errorThrown; + if ('file' in response.jqXHR.responseJSON) { + response.errorThrown = options.errorThrown = response.jqXHR.responseJSON.file.join(", "); + } this._trigger('fail', null, options); }, From d362c94a962788805ffbdc21f8594759b74a00e2 Mon Sep 17 00:00:00 2001 From: Sigurd Gartmann Date: Mon, 20 Jan 2014 13:03:05 +0100 Subject: [PATCH 05/20] Add csrf.js, as suggested by @ET-CS, fixes #49. --- fileupload/templates/fileupload/picture_jquery_form.html | 1 + 1 file changed, 1 insertion(+) diff --git a/fileupload/templates/fileupload/picture_jquery_form.html b/fileupload/templates/fileupload/picture_jquery_form.html index cad7980..cf0ed04 100644 --- a/fileupload/templates/fileupload/picture_jquery_form.html +++ b/fileupload/templates/fileupload/picture_jquery_form.html @@ -233,6 +233,7 @@

+ - + - + - + - + - + - + - + - + - + - + - + - + - - + + diff --git a/fileupload/templates/fileupload/picture_basic_form.html b/fileupload/templates/fileupload/picture_basic_form.html index 6bd17a4..69993d0 100644 --- a/fileupload/templates/fileupload/picture_basic_form.html +++ b/fileupload/templates/fileupload/picture_basic_form.html @@ -10,9 +10,9 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - - + + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - - - + + + -{% endblock %} \ No newline at end of file +{% endblock %} diff --git a/fileupload/templates/fileupload/picture_jquery_form.html b/fileupload/templates/fileupload/picture_jquery_form.html index cf0ed04..0332c31 100644 --- a/fileupload/templates/fileupload/picture_jquery_form.html +++ b/fileupload/templates/fileupload/picture_jquery_form.html @@ -24,9 +24,9 @@ - + - + - + - +