From 4fed2964d96e807ddffae741a56fdfb010a46ec3 Mon Sep 17 00:00:00 2001 From: Fabrizio Buratta Date: Thu, 6 Feb 2014 10:52:35 +0100 Subject: [PATCH 01/57] changed Pictures model to File --- fileupload/admin.py | 4 ++-- fileupload/models.py | 8 ++++---- fileupload/serialize.py | 7 ++++--- 3 files changed, 10 insertions(+), 9 deletions(-) diff --git a/fileupload/admin.py b/fileupload/admin.py index faa5cdc..8b5ec66 100644 --- a/fileupload/admin.py +++ b/fileupload/admin.py @@ -1,4 +1,4 @@ -from fileupload.models import Picture +from fileupload.models import File from django.contrib import admin -admin.site.register(Picture) \ No newline at end of file +admin.site.register(File) diff --git a/fileupload/models.py b/fileupload/models.py index f28d242..b33bd6f 100644 --- a/fileupload/models.py +++ b/fileupload/models.py @@ -2,14 +2,14 @@ from django.db import models -class Picture(models.Model): +class File(models.Model): """This is a small demo using just two fields. The slug field is really not necessary, but makes the code simpler. ImageField depends on PIL or pillow (where Pillow is easily installable in a virtualenv. If you have problems installing pillow, use a more generic FileField instead. """ - file = models.ImageField(upload_to="pictures") + file = models.FileField(upload_to="uploaded_files") slug = models.SlugField(max_length=50, blank=True) def __unicode__(self): @@ -21,9 +21,9 @@ def get_absolute_url(self): def save(self, *args, **kwargs): self.slug = self.file.name - super(Picture, self).save(*args, **kwargs) + super(File, self).save(*args, **kwargs) def delete(self, *args, **kwargs): """delete -- Remove to leave file.""" self.file.delete(False) - super(Picture, self).delete(*args, **kwargs) + super(File, self).delete(*args, **kwargs) diff --git a/fileupload/serialize.py b/fileupload/serialize.py index 4494e79..94e2d89 100644 --- a/fileupload/serialize.py +++ b/fileupload/serialize.py @@ -18,9 +18,9 @@ def order_name(name): def serialize(instance, file_attr='file'): - """serialize -- Serialize a Picture instance into a dict. + """serialize -- Serialize a File instance into a dict. - instance -- Picture instance + instance -- File instance file_attr -- attribute name that contains the FileField or ImageField """ @@ -28,7 +28,8 @@ def serialize(instance, file_attr='file'): return { 'url': obj.url, 'name': order_name(obj.name), - 'type': mimetypes.guess_type(obj.path)[0] or 'image/png', + #'type': mimetypes.guess_type(obj.path)[0] or 'image/png', + 'type': mimetypes.guess_type(obj.path)[0], 'thumbnailUrl': obj.url, 'size': obj.size, 'deleteUrl': reverse('upload-delete', args=[instance.pk]), From 2f3a8f1e50789ac1e4f0b50674e57bea83255d66 Mon Sep 17 00:00:00 2001 From: Fabrizio Buratta Date: Thu, 6 Feb 2014 10:52:58 +0100 Subject: [PATCH 02/57] added login and logout view --- fileupload/urls.py | 18 +++++++++++------- fileupload/views.py | 39 ++++++++++++++++++++++++++++----------- 2 files changed, 39 insertions(+), 18 deletions(-) diff --git a/fileupload/urls.py b/fileupload/urls.py index dbbcbca..3c86c65 100644 --- a/fileupload/urls.py +++ b/fileupload/urls.py @@ -1,17 +1,21 @@ # encoding: utf-8 from django.conf.urls import patterns, url + from fileupload.views import ( BasicVersionCreateView, BasicPlusVersionCreateView, jQueryVersionCreateView, AngularVersionCreateView, - PictureCreateView, PictureDeleteView, PictureListView, + FileCreateView, FileDeleteView, FileListView, + login_view, logout_view, ) urlpatterns = patterns('', - url(r'^basic/$', BasicVersionCreateView.as_view(), name='upload-basic'), - url(r'^basic/plus/$', BasicPlusVersionCreateView.as_view(), name='upload-basic-plus'), - url(r'^new/$', PictureCreateView.as_view(), name='upload-new'), - url(r'^angular/$', AngularVersionCreateView.as_view(), name='upload-angular'), + #url(r'^basic/$', BasicVersionCreateView.as_view(), name='upload-basic'), + #url(r'^basic/plus/$', BasicPlusVersionCreateView.as_view(), name='upload-basic-plus'), + #url(r'^new/$', FileCreateView.as_view(), name='upload-new'), + #url(r'^angular/$', AngularVersionCreateView.as_view(), name='upload-angular'), + url(r'^login/$', login_view, name='login'), + url(r'^logout/$', logout_view, name='logout'), url(r'^jquery-ui/$', jQueryVersionCreateView.as_view(), name='upload-jquery'), - url(r'^delete/(?P\d+)$', PictureDeleteView.as_view(), name='upload-delete'), - url(r'^view/$', PictureListView.as_view(), name='upload-view'), + url(r'^delete/(?P\d+)$', FileDeleteView.as_view(), name='upload-delete'), + url(r'^view/$', FileListView.as_view(), name='upload-view'), ) diff --git a/fileupload/views.py b/fileupload/views.py index 98b339c..457f7c3 100644 --- a/fileupload/views.py +++ b/fileupload/views.py @@ -3,13 +3,30 @@ from django.http import HttpResponse from django.views.generic import CreateView, DeleteView, ListView -from .models import Picture +from .models import File from .response import JSONResponse, response_mimetype from .serialize import serialize +from django.contrib.auth import authenticate, login +from django.contrib.auth import logout +from django.shortcuts import redirect +def logout_view(request): + logout(request) + return redirect('/upload/jquery-ui/') -class PictureCreateView(CreateView): - model = Picture +def login_view(request): + + username = request.POST['username'] + password = request.POST['password'] + user = authenticate(username=username, password=password) + if user is not None: + if user.is_active: + login(request, user) + + return redirect('/upload/jquery-ui/') + +class FileCreateView(CreateView): + model = File def form_valid(self, form): self.object = form.save() @@ -23,24 +40,24 @@ def form_invalid(self, form): data = json.dumps(form.errors) return HttpResponse(content=data, status=400, content_type='application/json') -class BasicVersionCreateView(PictureCreateView): +class BasicVersionCreateView(FileCreateView): template_name_suffix = '_basic_form' -class BasicPlusVersionCreateView(PictureCreateView): +class BasicPlusVersionCreateView(FileCreateView): template_name_suffix = '_basicplus_form' -class AngularVersionCreateView(PictureCreateView): +class AngularVersionCreateView(FileCreateView): template_name_suffix = '_angular_form' -class jQueryVersionCreateView(PictureCreateView): +class jQueryVersionCreateView(FileCreateView): template_name_suffix = '_jquery_form' -class PictureDeleteView(DeleteView): - model = Picture +class FileDeleteView(DeleteView): + model = File def delete(self, request, *args, **kwargs): self.object = self.get_object() @@ -50,8 +67,8 @@ def delete(self, request, *args, **kwargs): return response -class PictureListView(ListView): - model = Picture +class FileListView(ListView): + model = File def render_to_response(self, context, **response_kwargs): files = [ serialize(p) for p in self.get_queryset() ] From b67cf6210605d55c49115ae16766ef9f28d0df43 Mon Sep 17 00:00:00 2001 From: Fabrizio Buratta Date: Thu, 6 Feb 2014 10:53:50 +0100 Subject: [PATCH 03/57] added login form to jquery template --- .../fileupload/picture_jquery_form.html | 255 ------------------ 1 file changed, 255 deletions(-) delete mode 100644 fileupload/templates/fileupload/picture_jquery_form.html diff --git a/fileupload/templates/fileupload/picture_jquery_form.html b/fileupload/templates/fileupload/picture_jquery_form.html deleted file mode 100644 index cf0ed04..0000000 --- a/fileupload/templates/fileupload/picture_jquery_form.html +++ /dev/null @@ -1,255 +0,0 @@ - - - - - - - -Django jQuery File Upload Demo - jQuery UI version - - - - - - - - - - - - - - - - - -

Django jQuery File Upload Demo

-

jQuery UI version

-
- - -
- -
-

File Upload widget with multiple file selection, drag&drop support, progress bars, validation and preview images, audio and video for jQuery UI.
- Supports cross-domain, chunked and resumable file uploads and client-side image resizing.

-
- -
{% csrf_token %} - - - -
-
- - - Add files... - - - - - - - - -
- - -
- -
-
-
-

Demo Notes

-
    -
  • The maximum file size for uploads in this demo is 5 MB (default file size is unlimited).
  • -
  • Only image files (JPG, GIF, PNG) are allowed in this demo (by default there is no file type restriction).
  • -
  • Uploaded files will be deleted automatically after 5 minutes (demo setting).
  • -
  • You can drag & drop files from your desktop on this webpage (see Browser support).
  • -
  • Please refer to the project website and documentation for more information.
  • -
  • Built with jQuery UI.
  • -
- - -{% verbatim %} - - - - -{% endverbatim %} - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - From a737e50d9bfc6896f9dc079dc2ecfa57354375fb Mon Sep 17 00:00:00 2001 From: Fabrizio Buratta Date: Thu, 6 Feb 2014 11:08:48 +0100 Subject: [PATCH 04/57] templates adjustement --- fileupload/static/css/demo.css | 4 +- .../fileupload/picture_angular_form.html | 207 ---------------- .../fileupload/picture_basic_form.html | 130 ----------- .../fileupload/picture_basicplus_form.html | 221 ------------------ .../templates/fileupload/picture_form.html | 126 ---------- fileupload/templates/upload_base.html | 2 +- urls.py | 2 +- 7 files changed, 4 insertions(+), 688 deletions(-) delete mode 100644 fileupload/templates/fileupload/picture_angular_form.html delete mode 100644 fileupload/templates/fileupload/picture_basic_form.html delete mode 100644 fileupload/templates/fileupload/picture_basicplus_form.html delete mode 100644 fileupload/templates/fileupload/picture_form.html diff --git a/fileupload/static/css/demo.css b/fileupload/static/css/demo.css index 841f80d..fb02909 100644 --- a/fileupload/static/css/demo.css +++ b/fileupload/static/css/demo.css @@ -17,8 +17,8 @@ body { font-family: 'Lucida Grande', 'Lucida Sans Unicode', Arial, sans-serif; font-size: 1em; line-height: 1.4em; - background: #222; - color: #fff; + background: #E2E2E2; + color: #111; -webkit-text-size-adjust: 100%; -ms-text-size-adjust: 100%; } diff --git a/fileupload/templates/fileupload/picture_angular_form.html b/fileupload/templates/fileupload/picture_angular_form.html deleted file mode 100644 index a5ac9c0..0000000 --- a/fileupload/templates/fileupload/picture_angular_form.html +++ /dev/null @@ -1,207 +0,0 @@ - - - - - - - -jQuery File Upload Demo - AngularJS version - - - - - - - - - - - - - - - - -
-

Django jQuery File Upload Demo

-

AngularJS version

- -
-
-

File Upload widget with multiple file selection, drag&drop support, progress bars, validation and preview images, audio and video for AngularJS.
- Supports cross-domain, chunked and resumable file uploads and client-side image resizing.

-
-
- -
{% csrf_token %} - - - -
-
- - - - Add files... - - - - - -
-
- -
- -
- -
 
-
-
- {% verbatim %} - - - - - - - - -
-
- -
-
-
-

- - {{file.name}} - {{file.name}} - - {{file.name}} -

-
Error {{file.error}}
-
-

{{file.size | formatFileSize}}

-
-
- - - -
- {% endverbatim %} -
-
-
-
-

Demo Notes

-
-
- -
-
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/fileupload/templates/fileupload/picture_basic_form.html b/fileupload/templates/fileupload/picture_basic_form.html deleted file mode 100644 index 6bd17a4..0000000 --- a/fileupload/templates/fileupload/picture_basic_form.html +++ /dev/null @@ -1,130 +0,0 @@ - - - - - - -Django jQuery File Upload Demo - Basic version - - - - - - - - - - - -
-

Django jQuery File Upload Demo

-

Basic version

- -
-
-

File Upload widget with multiple file selection, drag&drop support and progress bar for jQuery.
- Supports cross-domain, chunked and resumable file uploads.

-
-
- - - - Select files... - - - -
-
- -
-
-
- -
-
-
-
-

Demo Notes

-
-
- -
-
-
- - - - - - - - - - - - - diff --git a/fileupload/templates/fileupload/picture_basicplus_form.html b/fileupload/templates/fileupload/picture_basicplus_form.html deleted file mode 100644 index eb1cc1c..0000000 --- a/fileupload/templates/fileupload/picture_basicplus_form.html +++ /dev/null @@ -1,221 +0,0 @@ - - - - - - -jQuery File Upload Demo - Basic Plus version - - - - - - - - - - - -
-

Django jQuery File Upload Demo

-

Basic Plus version

- -
-
-

File Upload widget with multiple file selection, drag&drop support, progress bar, validation and preview images, audio and video for jQuery.
- Supports cross-domain, chunked and resumable file uploads and client-side image resizing.

-
-
- - - - Add files... - - - -
-
- -
-
-
- -
-
-
-
-

Demo Notes

-
-
-
    -
  • The maximum file size for uploads in this demo is 5 MB (default file size is unlimited).
  • -
  • Only image files (JPG, GIF, PNG) are allowed in this demo (by default there is no file type restriction).
  • -
  • You can drag & drop files from your desktop on this webpage (see Browser support).
  • -
  • Please refer to the project website and documentation for more information.
  • -
  • Built with Twitter's Bootstrap CSS framework and Icons from Glyphicons.
  • -
-
-
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/fileupload/templates/fileupload/picture_form.html b/fileupload/templates/fileupload/picture_form.html deleted file mode 100644 index a8754bc..0000000 --- a/fileupload/templates/fileupload/picture_form.html +++ /dev/null @@ -1,126 +0,0 @@ -{% extends "upload_base.html" %} -{% load upload_tags %} - -{% block content %} -
-

Django jQuery File Upload Demo

-

Basic Plus UI version

- -
-
-

File Upload widget with multiple file selection, drag&drop support, progress bars, validation and preview images, audio and video for jQuery.
- Supports cross-domain, chunked and resumable file uploads and client-side image resizing.

-
-
- -
{% csrf_token %} - - - -
-
- - - - Add files... - - - - - - - - -
- -
- -
-
-
- -
 
-
-
- - -
-
-
-
-

Demo Notes

-
-
- -
-
-
- - -{% upload_js %} - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -{% endblock %} \ No newline at end of file diff --git a/fileupload/templates/upload_base.html b/fileupload/templates/upload_base.html index e75c3fc..dd94ee0 100644 --- a/fileupload/templates/upload_base.html +++ b/fileupload/templates/upload_base.html @@ -7,7 +7,7 @@ Django Jquery file upload demo - + diff --git a/urls.py b/urls.py index 00270ad..97afb62 100644 --- a/urls.py +++ b/urls.py @@ -9,7 +9,7 @@ # Examples: # url(r'^$', 'upload.views.home', name='home'), - url(r'^$', lambda x: HttpResponseRedirect('/upload/new/')), + url(r'^$', lambda x: HttpResponseRedirect('/upload/jquery-ui/')), url(r'^upload/', include('fileupload.urls')), # Uncomment the admin/doc line below to enable admin documentation: From c528995452ff7247cf6c94f1210fc12447611807 Mon Sep 17 00:00:00 2001 From: Fabrizio Buratta Date: Thu, 6 Feb 2014 11:21:16 +0100 Subject: [PATCH 05/57] templates stuff --- fileupload/static/css/demo.css | 4 +- .../fileupload/picture_angular_form.html | 207 ---------------- .../fileupload/picture_basic_form.html | 130 ----------- .../fileupload/picture_basicplus_form.html | 221 ------------------ .../templates/fileupload/picture_form.html | 126 ---------- fileupload/templates/upload_base.html | 2 +- urls.py | 2 +- 7 files changed, 4 insertions(+), 688 deletions(-) delete mode 100644 fileupload/templates/fileupload/picture_angular_form.html delete mode 100644 fileupload/templates/fileupload/picture_basic_form.html delete mode 100644 fileupload/templates/fileupload/picture_basicplus_form.html delete mode 100644 fileupload/templates/fileupload/picture_form.html diff --git a/fileupload/static/css/demo.css b/fileupload/static/css/demo.css index 841f80d..fb02909 100644 --- a/fileupload/static/css/demo.css +++ b/fileupload/static/css/demo.css @@ -17,8 +17,8 @@ body { font-family: 'Lucida Grande', 'Lucida Sans Unicode', Arial, sans-serif; font-size: 1em; line-height: 1.4em; - background: #222; - color: #fff; + background: #E2E2E2; + color: #111; -webkit-text-size-adjust: 100%; -ms-text-size-adjust: 100%; } diff --git a/fileupload/templates/fileupload/picture_angular_form.html b/fileupload/templates/fileupload/picture_angular_form.html deleted file mode 100644 index a5ac9c0..0000000 --- a/fileupload/templates/fileupload/picture_angular_form.html +++ /dev/null @@ -1,207 +0,0 @@ - - - - - - - -jQuery File Upload Demo - AngularJS version - - - - - - - - - - - - - - - - -
-

Django jQuery File Upload Demo

-

AngularJS version

- -
-
-

File Upload widget with multiple file selection, drag&drop support, progress bars, validation and preview images, audio and video for AngularJS.
- Supports cross-domain, chunked and resumable file uploads and client-side image resizing.

-
-
- -
{% csrf_token %} - - - -
-
- - - - Add files... - - - - - -
-
- -
- -
- -
 
-
-
- {% verbatim %} - - - - - - - - -
-
- -
-
-
-

- - {{file.name}} - {{file.name}} - - {{file.name}} -

-
Error {{file.error}}
-
-

{{file.size | formatFileSize}}

-
-
- - - -
- {% endverbatim %} -
-
-
-
-

Demo Notes

-
-
- -
-
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/fileupload/templates/fileupload/picture_basic_form.html b/fileupload/templates/fileupload/picture_basic_form.html deleted file mode 100644 index 6bd17a4..0000000 --- a/fileupload/templates/fileupload/picture_basic_form.html +++ /dev/null @@ -1,130 +0,0 @@ - - - - - - -Django jQuery File Upload Demo - Basic version - - - - - - - - - - - -
-

Django jQuery File Upload Demo

-

Basic version

- -
-
-

File Upload widget with multiple file selection, drag&drop support and progress bar for jQuery.
- Supports cross-domain, chunked and resumable file uploads.

-
-
- - - - Select files... - - - -
-
- -
-
-
- -
-
-
-
-

Demo Notes

-
-
- -
-
-
- - - - - - - - - - - - - diff --git a/fileupload/templates/fileupload/picture_basicplus_form.html b/fileupload/templates/fileupload/picture_basicplus_form.html deleted file mode 100644 index eb1cc1c..0000000 --- a/fileupload/templates/fileupload/picture_basicplus_form.html +++ /dev/null @@ -1,221 +0,0 @@ - - - - - - -jQuery File Upload Demo - Basic Plus version - - - - - - - - - - - -
-

Django jQuery File Upload Demo

-

Basic Plus version

- -
-
-

File Upload widget with multiple file selection, drag&drop support, progress bar, validation and preview images, audio and video for jQuery.
- Supports cross-domain, chunked and resumable file uploads and client-side image resizing.

-
-
- - - - Add files... - - - -
-
- -
-
-
- -
-
-
-
-

Demo Notes

-
-
-
    -
  • The maximum file size for uploads in this demo is 5 MB (default file size is unlimited).
  • -
  • Only image files (JPG, GIF, PNG) are allowed in this demo (by default there is no file type restriction).
  • -
  • You can drag & drop files from your desktop on this webpage (see Browser support).
  • -
  • Please refer to the project website and documentation for more information.
  • -
  • Built with Twitter's Bootstrap CSS framework and Icons from Glyphicons.
  • -
-
-
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/fileupload/templates/fileupload/picture_form.html b/fileupload/templates/fileupload/picture_form.html deleted file mode 100644 index a8754bc..0000000 --- a/fileupload/templates/fileupload/picture_form.html +++ /dev/null @@ -1,126 +0,0 @@ -{% extends "upload_base.html" %} -{% load upload_tags %} - -{% block content %} -
-

Django jQuery File Upload Demo

-

Basic Plus UI version

- -
-
-

File Upload widget with multiple file selection, drag&drop support, progress bars, validation and preview images, audio and video for jQuery.
- Supports cross-domain, chunked and resumable file uploads and client-side image resizing.

-
-
- -
{% csrf_token %} - - - -
-
- - - - Add files... - - - - - - - - -
- -
- -
-
-
- -
 
-
-
- - -
-
-
-
-

Demo Notes

-
-
- -
-
-
- - -{% upload_js %} - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -{% endblock %} \ No newline at end of file diff --git a/fileupload/templates/upload_base.html b/fileupload/templates/upload_base.html index e75c3fc..dd94ee0 100644 --- a/fileupload/templates/upload_base.html +++ b/fileupload/templates/upload_base.html @@ -7,7 +7,7 @@ Django Jquery file upload demo - + diff --git a/urls.py b/urls.py index 00270ad..97afb62 100644 --- a/urls.py +++ b/urls.py @@ -9,7 +9,7 @@ # Examples: # url(r'^$', 'upload.views.home', name='home'), - url(r'^$', lambda x: HttpResponseRedirect('/upload/new/')), + url(r'^$', lambda x: HttpResponseRedirect('/upload/jquery-ui/')), url(r'^upload/', include('fileupload.urls')), # Uncomment the admin/doc line below to enable admin documentation: From eba9d72ffdadc968c9cff3670c84860faceb022f Mon Sep 17 00:00:00 2001 From: Fabrizio Buratta Date: Thu, 6 Feb 2014 11:25:40 +0100 Subject: [PATCH 06/57] add uploader templates --- .../fileupload/file_angular_form.html | 207 ++++++++++++++++ .../templates/fileupload/file_basic_form.html | 130 ++++++++++ .../fileupload/file_basicplus_form.html | 221 +++++++++++++++++ .../templates/fileupload/file_form.html | 126 ++++++++++ .../fileupload/file_jquery_form.html | 234 ++++++++++++++++++ .../fileupload/file_jquery_form.html.b | 204 +++++++++++++++ 6 files changed, 1122 insertions(+) create mode 100644 fileupload/templates/fileupload/file_angular_form.html create mode 100644 fileupload/templates/fileupload/file_basic_form.html create mode 100644 fileupload/templates/fileupload/file_basicplus_form.html create mode 100644 fileupload/templates/fileupload/file_form.html create mode 100644 fileupload/templates/fileupload/file_jquery_form.html create mode 100644 fileupload/templates/fileupload/file_jquery_form.html.b diff --git a/fileupload/templates/fileupload/file_angular_form.html b/fileupload/templates/fileupload/file_angular_form.html new file mode 100644 index 0000000..a5ac9c0 --- /dev/null +++ b/fileupload/templates/fileupload/file_angular_form.html @@ -0,0 +1,207 @@ + + + + + + + +jQuery File Upload Demo - AngularJS version + + + + + + + + + + + + + + + + +
+

Django jQuery File Upload Demo

+

AngularJS version

+ +
+
+

File Upload widget with multiple file selection, drag&drop support, progress bars, validation and preview images, audio and video for AngularJS.
+ Supports cross-domain, chunked and resumable file uploads and client-side image resizing.

+
+
+ +
{% csrf_token %} + + + +
+
+ + + + Add files... + + + + + +
+
+ +
+ +
+ +
 
+
+
+ {% verbatim %} + + + + + + + + +
+
+ +
+
+
+

+ + {{file.name}} + {{file.name}} + + {{file.name}} +

+
Error {{file.error}}
+
+

{{file.size | formatFileSize}}

+
+
+ + + +
+ {% endverbatim %} +
+
+
+
+

Demo Notes

+
+
+ +
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/fileupload/templates/fileupload/file_basic_form.html b/fileupload/templates/fileupload/file_basic_form.html new file mode 100644 index 0000000..6bd17a4 --- /dev/null +++ b/fileupload/templates/fileupload/file_basic_form.html @@ -0,0 +1,130 @@ + + + + + + +Django jQuery File Upload Demo - Basic version + + + + + + + + + + + +
+

Django jQuery File Upload Demo

+

Basic version

+ +
+
+

File Upload widget with multiple file selection, drag&drop support and progress bar for jQuery.
+ Supports cross-domain, chunked and resumable file uploads.

+
+
+ + + + Select files... + + + +
+
+ +
+
+
+ +
+
+
+
+

Demo Notes

+
+
+ +
+
+
+ + + + + + + + + + + + + diff --git a/fileupload/templates/fileupload/file_basicplus_form.html b/fileupload/templates/fileupload/file_basicplus_form.html new file mode 100644 index 0000000..eb1cc1c --- /dev/null +++ b/fileupload/templates/fileupload/file_basicplus_form.html @@ -0,0 +1,221 @@ + + + + + + +jQuery File Upload Demo - Basic Plus version + + + + + + + + + + + +
+

Django jQuery File Upload Demo

+

Basic Plus version

+ +
+
+

File Upload widget with multiple file selection, drag&drop support, progress bar, validation and preview images, audio and video for jQuery.
+ Supports cross-domain, chunked and resumable file uploads and client-side image resizing.

+
+
+ + + + Add files... + + + +
+
+ +
+
+
+ +
+
+
+
+

Demo Notes

+
+
+
    +
  • The maximum file size for uploads in this demo is 5 MB (default file size is unlimited).
  • +
  • Only image files (JPG, GIF, PNG) are allowed in this demo (by default there is no file type restriction).
  • +
  • You can drag & drop files from your desktop on this webpage (see Browser support).
  • +
  • Please refer to the project website and documentation for more information.
  • +
  • Built with Twitter's Bootstrap CSS framework and Icons from Glyphicons.
  • +
+
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/fileupload/templates/fileupload/file_form.html b/fileupload/templates/fileupload/file_form.html new file mode 100644 index 0000000..a8754bc --- /dev/null +++ b/fileupload/templates/fileupload/file_form.html @@ -0,0 +1,126 @@ +{% extends "upload_base.html" %} +{% load upload_tags %} + +{% block content %} +
+

Django jQuery File Upload Demo

+

Basic Plus UI version

+ +
+
+

File Upload widget with multiple file selection, drag&drop support, progress bars, validation and preview images, audio and video for jQuery.
+ Supports cross-domain, chunked and resumable file uploads and client-side image resizing.

+
+
+ +
{% csrf_token %} + + + +
+
+ + + + Add files... + + + + + + + + +
+ +
+ +
+
+
+ +
 
+
+
+ + +
+
+
+
+

Demo Notes

+
+
+ +
+
+
+ + +{% upload_js %} + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +{% endblock %} \ No newline at end of file diff --git a/fileupload/templates/fileupload/file_jquery_form.html b/fileupload/templates/fileupload/file_jquery_form.html new file mode 100644 index 0000000..8e510fd --- /dev/null +++ b/fileupload/templates/fileupload/file_jquery_form.html @@ -0,0 +1,234 @@ + + + + + + + +Molecular Discovery Secure File Upload + + + + + + + + + + + + + + + + +{% block contents %} +{% if user.is_authenticated %} +
+ + + +
{% csrf_token %} + + + +
+
+ + + Add files... + + + + + + + + +
+ + +
+ +
+
+ + + +
+{% else %} +
+

Welcome

+

+ This app has te purpose to show how to implement github-like notifications.
+ Please login with test/test username and password. +

+
+ {% csrf_token %} +
+ + +
+
+ + +
+ +
+
+{% endif %} +{% endblock %} + + +
+ + +{% verbatim %} + + + + +{% endverbatim %} + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/fileupload/templates/fileupload/file_jquery_form.html.b b/fileupload/templates/fileupload/file_jquery_form.html.b new file mode 100644 index 0000000..0a35fc1 --- /dev/null +++ b/fileupload/templates/fileupload/file_jquery_form.html.b @@ -0,0 +1,204 @@ + + + + + + + +Molecular Discovery Secure File Upload + + + + + + + + + + + + + + + + + + +
{% csrf_token %} + + + +
+
+ + + Add files... + + + + + + + + +
+ + +
+ +
+
+
+ + +{% verbatim %} + + + + +{% endverbatim %} + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + From 6ac01b07d7b1731145b5f1a3e94688ecc0d243fa Mon Sep 17 00:00:00 2001 From: Fabrizio Buratta Date: Thu, 6 Feb 2014 16:43:13 +0100 Subject: [PATCH 07/57] fileField runtime path for user --- fileupload/models.py | 7 +++++-- .../templates/fileupload/file_jquery_form.html | 12 ++---------- fileupload/views.py | 7 +++++++ 3 files changed, 14 insertions(+), 12 deletions(-) diff --git a/fileupload/models.py b/fileupload/models.py index b33bd6f..27b8210 100644 --- a/fileupload/models.py +++ b/fileupload/models.py @@ -1,6 +1,8 @@ # encoding: utf-8 from django.db import models +def upload_dir_path(instance, filename): + return 'uploaded_files/%s/%s' % (instance.username, filename) class File(models.Model): """This is a small demo using just two fields. The slug field is really not @@ -9,8 +11,9 @@ class File(models.Model): problems installing pillow, use a more generic FileField instead. """ - file = models.FileField(upload_to="uploaded_files") - slug = models.SlugField(max_length=50, blank=True) + file = models.FileField(upload_to=upload_dir_path) + slug = models.SlugField(max_length=50, blank=True ) + username = models.CharField(max_length=50) def __unicode__(self): return self.file.name diff --git a/fileupload/templates/fileupload/file_jquery_form.html b/fileupload/templates/fileupload/file_jquery_form.html index 8e510fd..a01e959 100644 --- a/fileupload/templates/fileupload/file_jquery_form.html +++ b/fileupload/templates/fileupload/file_jquery_form.html @@ -68,6 +68,7 @@ + @@ -111,16 +112,7 @@

Welcome


- - + {% verbatim %} +{% endverbatim %} + +{% if perms.fileupload %} + +{% verbatim %} {% endverbatim %} + +{% else %} + +{% verbatim %} + + +{% endverbatim %} + + +{% endif %} + From fa5a22d7582ea2e956447ff77bb0636cb4a9f1c1 Mon Sep 17 00:00:00 2001 From: Fabrizio Buratta Date: Wed, 19 Feb 2014 17:02:23 +0100 Subject: [PATCH 15/57] improved shortning and formatting --- fileupload/serialize.py | 4 ++-- fileupload/static/css/demo.css | 9 +++++++-- fileupload/templates/fileupload/file_jquery_form.html | 2 +- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/fileupload/serialize.py b/fileupload/serialize.py index 94e2d89..868a17d 100644 --- a/fileupload/serialize.py +++ b/fileupload/serialize.py @@ -12,9 +12,9 @@ def order_name(name): """ name = re.sub(r'^.*/', '', name) - if len(name) <= 20: + if len(name) <= 37: return name - return name[:10] + "..." + name[-7:] + return name[:37] + "..." + name[-7:] def serialize(instance, file_attr='file'): diff --git a/fileupload/static/css/demo.css b/fileupload/static/css/demo.css index c6bbd91..a48754a 100644 --- a/fileupload/static/css/demo.css +++ b/fileupload/static/css/demo.css @@ -40,11 +40,16 @@ blockquote { border-left: 5px solid #eee; } table { - width: 100%; - margin: 10px 0; + width: auto; + margin: 10px 10; } +table td +{ + padding-right: 25px; +} + .mdtitle h2{ font-size: 17px; } diff --git a/fileupload/templates/fileupload/file_jquery_form.html b/fileupload/templates/fileupload/file_jquery_form.html index d772988..b7254ab 100644 --- a/fileupload/templates/fileupload/file_jquery_form.html +++ b/fileupload/templates/fileupload/file_jquery_form.html @@ -87,7 +87,7 @@ - +
From 2c49212aeae0a079e72122a001ca12815d40d07d Mon Sep 17 00:00:00 2001 From: Fabrizio Buratta Date: Wed, 19 Feb 2014 17:21:20 +0100 Subject: [PATCH 16/57] added logged in message --- fileupload/templates/fileupload/file_jquery_form.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fileupload/templates/fileupload/file_jquery_form.html b/fileupload/templates/fileupload/file_jquery_form.html index b7254ab..8b88900 100644 --- a/fileupload/templates/fileupload/file_jquery_form.html +++ b/fileupload/templates/fileupload/file_jquery_form.html @@ -56,7 +56,7 @@

File:

Size:

{% csrf_token %} From ccdd4093b0f5999656ea01ce0c1e46caacd2f120 Mon Sep 17 00:00:00 2001 From: Fabrizio Buratta Date: Wed, 19 Feb 2014 17:38:33 +0100 Subject: [PATCH 17/57] login page cleanup --- fileupload/templates/fileupload/file_jquery_form.html | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/fileupload/templates/fileupload/file_jquery_form.html b/fileupload/templates/fileupload/file_jquery_form.html index 8b88900..a95e352 100644 --- a/fileupload/templates/fileupload/file_jquery_form.html +++ b/fileupload/templates/fileupload/file_jquery_form.html @@ -101,21 +101,20 @@ {% else %}
-

Welcome

+

Molecular Discovery Secure Upload Login.

- This app has te purpose to show how to implement github-like notifications.
- Please login with test/test username and password. + Please use the login credential that our staff provided you:

{% csrf_token %}
- +
- -
+ +

From de6fcad92c8317b08591d7a935b2d0930ad41e50 Mon Sep 17 00:00:00 2001 From: Fabrizio Buratta Date: Fri, 21 Feb 2014 11:37:41 +0100 Subject: [PATCH 18/57] removed unused templates --- .../fileupload/file_angular_form.html | 207 ---------------- .../templates/fileupload/file_basic_form.html | 130 ----------- .../fileupload/file_basicplus_form.html | 221 ------------------ .../templates/fileupload/file_form.html | 126 ---------- .../fileupload/file_jquery_form.html.b | 204 ---------------- fileupload/templates/upload_base.html | 52 ----- fileupload/urls.py | 4 - 7 files changed, 944 deletions(-) delete mode 100644 fileupload/templates/fileupload/file_angular_form.html delete mode 100644 fileupload/templates/fileupload/file_basic_form.html delete mode 100644 fileupload/templates/fileupload/file_basicplus_form.html delete mode 100644 fileupload/templates/fileupload/file_form.html delete mode 100644 fileupload/templates/fileupload/file_jquery_form.html.b delete mode 100644 fileupload/templates/upload_base.html diff --git a/fileupload/templates/fileupload/file_angular_form.html b/fileupload/templates/fileupload/file_angular_form.html deleted file mode 100644 index a5ac9c0..0000000 --- a/fileupload/templates/fileupload/file_angular_form.html +++ /dev/null @@ -1,207 +0,0 @@ - - - - - - - -jQuery File Upload Demo - AngularJS version - - - - - - - - - - - - - - - - -
-

Django jQuery File Upload Demo

-

AngularJS version

- -
-
-

File Upload widget with multiple file selection, drag&drop support, progress bars, validation and preview images, audio and video for AngularJS.
- Supports cross-domain, chunked and resumable file uploads and client-side image resizing.

-
-
- -
{% csrf_token %} - - - -
-
- - - - Add files... - - - - - -
-
- -
- -
- -
 
-
-
- {% verbatim %} - - - - - - - - -
-
- -
-
-
-

- - {{file.name}} - {{file.name}} - - {{file.name}} -

-
Error {{file.error}}
-
-

{{file.size | formatFileSize}}

-
-
- - - -
- {% endverbatim %} -
-
-
-
-

Demo Notes

-
-
- -
-
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/fileupload/templates/fileupload/file_basic_form.html b/fileupload/templates/fileupload/file_basic_form.html deleted file mode 100644 index 6bd17a4..0000000 --- a/fileupload/templates/fileupload/file_basic_form.html +++ /dev/null @@ -1,130 +0,0 @@ - - - - - - -Django jQuery File Upload Demo - Basic version - - - - - - - - - - - -
-

Django jQuery File Upload Demo

-

Basic version

- -
-
-

File Upload widget with multiple file selection, drag&drop support and progress bar for jQuery.
- Supports cross-domain, chunked and resumable file uploads.

-
-
- - - - Select files... - - - -
-
- -
-
-
- -
-
-
-
-

Demo Notes

-
-
- -
-
-
- - - - - - - - - - - - - diff --git a/fileupload/templates/fileupload/file_basicplus_form.html b/fileupload/templates/fileupload/file_basicplus_form.html deleted file mode 100644 index eb1cc1c..0000000 --- a/fileupload/templates/fileupload/file_basicplus_form.html +++ /dev/null @@ -1,221 +0,0 @@ - - - - - - -jQuery File Upload Demo - Basic Plus version - - - - - - - - - - - -
-

Django jQuery File Upload Demo

-

Basic Plus version

- -
-
-

File Upload widget with multiple file selection, drag&drop support, progress bar, validation and preview images, audio and video for jQuery.
- Supports cross-domain, chunked and resumable file uploads and client-side image resizing.

-
-
- - - - Add files... - - - -
-
- -
-
-
- -
-
-
-
-

Demo Notes

-
-
-
    -
  • The maximum file size for uploads in this demo is 5 MB (default file size is unlimited).
  • -
  • Only image files (JPG, GIF, PNG) are allowed in this demo (by default there is no file type restriction).
  • -
  • You can drag & drop files from your desktop on this webpage (see Browser support).
  • -
  • Please refer to the project website and documentation for more information.
  • -
  • Built with Twitter's Bootstrap CSS framework and Icons from Glyphicons.
  • -
-
-
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/fileupload/templates/fileupload/file_form.html b/fileupload/templates/fileupload/file_form.html deleted file mode 100644 index a8754bc..0000000 --- a/fileupload/templates/fileupload/file_form.html +++ /dev/null @@ -1,126 +0,0 @@ -{% extends "upload_base.html" %} -{% load upload_tags %} - -{% block content %} -
-

Django jQuery File Upload Demo

-

Basic Plus UI version

- -
-
-

File Upload widget with multiple file selection, drag&drop support, progress bars, validation and preview images, audio and video for jQuery.
- Supports cross-domain, chunked and resumable file uploads and client-side image resizing.

-
-
- -
{% csrf_token %} - - - -
-
- - - - Add files... - - - - - - - - -
- -
- -
-
-
- -
 
-
-
- - -
-
-
-
-

Demo Notes

-
-
- -
-
-
- - -{% upload_js %} - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -{% endblock %} \ No newline at end of file diff --git a/fileupload/templates/fileupload/file_jquery_form.html.b b/fileupload/templates/fileupload/file_jquery_form.html.b deleted file mode 100644 index 0a35fc1..0000000 --- a/fileupload/templates/fileupload/file_jquery_form.html.b +++ /dev/null @@ -1,204 +0,0 @@ - - - - - - - -Molecular Discovery Secure File Upload - - - - - - - - - - - - - - - - - - -
{% csrf_token %} - - - -
-
- - - Add files... - - - - - - - - -
- - -
- -
-
-
- - -{% verbatim %} - - - - -{% endverbatim %} - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/fileupload/templates/upload_base.html b/fileupload/templates/upload_base.html deleted file mode 100644 index dd94ee0..0000000 --- a/fileupload/templates/upload_base.html +++ /dev/null @@ -1,52 +0,0 @@ - - - - - - - Django Jquery file upload demo - - - - - - - - - - - - - - - - - - - -{% block content %} -

No content set

-{% endblock %} - - - diff --git a/fileupload/urls.py b/fileupload/urls.py index 3c86c65..157a454 100644 --- a/fileupload/urls.py +++ b/fileupload/urls.py @@ -9,10 +9,6 @@ ) urlpatterns = patterns('', - #url(r'^basic/$', BasicVersionCreateView.as_view(), name='upload-basic'), - #url(r'^basic/plus/$', BasicPlusVersionCreateView.as_view(), name='upload-basic-plus'), - #url(r'^new/$', FileCreateView.as_view(), name='upload-new'), - #url(r'^angular/$', AngularVersionCreateView.as_view(), name='upload-angular'), url(r'^login/$', login_view, name='login'), url(r'^logout/$', logout_view, name='logout'), url(r'^jquery-ui/$', jQueryVersionCreateView.as_view(), name='upload-jquery'), From 24e8ba59522501212dd88e11f32a31c8e2bb12b1 Mon Sep 17 00:00:00 2001 From: Fabrizio Buratta Date: Fri, 21 Feb 2014 16:38:34 +0100 Subject: [PATCH 19/57] using https for ajax --- fileupload/templates/fileupload/file_jquery_form.html | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/fileupload/templates/fileupload/file_jquery_form.html b/fileupload/templates/fileupload/file_jquery_form.html index a95e352..95ec1bf 100644 --- a/fileupload/templates/fileupload/file_jquery_form.html +++ b/fileupload/templates/fileupload/file_jquery_form.html @@ -22,7 +22,7 @@ - +
{% csrf_token %} - +
@@ -203,8 +203,8 @@

Molecular Discovery Secure Upload Login.

{% endif %} - - + + From e36026e52ef19a10fa234d05c6692b1ce83b208b Mon Sep 17 00:00:00 2001 From: Fabrizio Buratta Date: Mon, 24 Feb 2014 13:21:19 +0100 Subject: [PATCH 20/57] removed jquery url --- fileupload/urls.py | 2 +- urls.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/fileupload/urls.py b/fileupload/urls.py index 157a454..357f433 100644 --- a/fileupload/urls.py +++ b/fileupload/urls.py @@ -11,7 +11,7 @@ urlpatterns = patterns('', url(r'^login/$', login_view, name='login'), url(r'^logout/$', logout_view, name='logout'), - url(r'^jquery-ui/$', jQueryVersionCreateView.as_view(), name='upload-jquery'), + url(r'^home/$', jQueryVersionCreateView.as_view(), name='upload-jquery'), url(r'^delete/(?P\d+)$', FileDeleteView.as_view(), name='upload-delete'), url(r'^view/$', FileListView.as_view(), name='upload-view'), ) diff --git a/urls.py b/urls.py index d3c3b8a..e7ae398 100644 --- a/urls.py +++ b/urls.py @@ -9,7 +9,7 @@ # Examples: # url(r'^$', 'upload.views.home', name='home'), - url(r'^$', lambda x: HttpResponseRedirect('upload/jquery-ui/'), name='home'), + url(r'^$', lambda x: HttpResponseRedirect('upload/home'), name='home'), url(r'^upload/', include('fileupload.urls')), # Uncomment the admin/doc line below to enable admin documentation: From cbfb07ee23bb91e971fc2c301edf06bc0f45c163 Mon Sep 17 00:00:00 2001 From: Fabrizio Buratta Date: Mon, 24 Feb 2014 13:21:30 +0100 Subject: [PATCH 21/57] fixed uploaded files visualization --- fileupload/static/css/demo.css | 4 +-- .../fileupload/file_jquery_form.html | 27 +++++++++++-------- 2 files changed, 18 insertions(+), 13 deletions(-) diff --git a/fileupload/static/css/demo.css b/fileupload/static/css/demo.css index a48754a..d5d5b0e 100644 --- a/fileupload/static/css/demo.css +++ b/fileupload/static/css/demo.css @@ -40,14 +40,14 @@ blockquote { border-left: 5px solid #eee; } table { - width: auto; + width: 100%; margin: 10px 10; } table td { - padding-right: 25px; + padding-right: 5px; } .mdtitle h2{ diff --git a/fileupload/templates/fileupload/file_jquery_form.html b/fileupload/templates/fileupload/file_jquery_form.html index 95ec1bf..aeea3d2 100644 --- a/fileupload/templates/fileupload/file_jquery_form.html +++ b/fileupload/templates/fileupload/file_jquery_form.html @@ -87,12 +87,12 @@
- +
@@ -100,8 +100,8 @@ {% else %} -
-

Molecular Discovery Secure Upload Login.

+
+

Molecular Discovery Secure Upload Login.

Please use the login credential that our staff provided you:

@@ -109,11 +109,11 @@

Molecular Discovery Secure Upload Login.

{% csrf_token %}
- +
- - + +

@@ -128,9 +128,6 @@

Molecular Discovery Secure Upload Login.

{% for (var i=0, file; file=o.files[i]; i++) { %} -

{%=file.name%}

{% if (file.error) { %} @@ -161,8 +158,16 @@

Molecular Discovery Secure Upload Login.

{% verbatim %} + + {% if (o.files.length>1) { %} +

File:

+

Size:

+

Action:

+ + {% } %}` + {% for (var i=0, file; file=o.files[i]; i++) { %} - +{

{%=file.name%}

From a21b09a4270212a61ae9461fafa2d926099eb0ca Mon Sep 17 00:00:00 2001 From: Fabrizio Buratta Date: Mon, 24 Feb 2014 13:35:32 +0100 Subject: [PATCH 22/57] commented file/size/action row TO fix --- fileupload/templates/fileupload/file_jquery_form.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/fileupload/templates/fileupload/file_jquery_form.html b/fileupload/templates/fileupload/file_jquery_form.html index aeea3d2..077b959 100644 --- a/fileupload/templates/fileupload/file_jquery_form.html +++ b/fileupload/templates/fileupload/file_jquery_form.html @@ -159,12 +159,12 @@

Molecular Discovery Secure Upload Login.

- {% if (o.files.length>1) { %} + {% for (var i=0, file; file=o.files[i]; i++) { %} { From 85df554b106e842c3b848e4ca9b5392717d706cd Mon Sep 17 00:00:00 2001 From: Fabrizio Buratta Date: Mon, 24 Feb 2014 16:53:45 +0100 Subject: [PATCH 23/57] cancel button only if user has permissions --- fileupload/templates/fileupload/file_jquery_form.html | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/fileupload/templates/fileupload/file_jquery_form.html b/fileupload/templates/fileupload/file_jquery_form.html index 077b959..d4516ad 100644 --- a/fileupload/templates/fileupload/file_jquery_form.html +++ b/fileupload/templates/fileupload/file_jquery_form.html @@ -71,9 +71,15 @@
+ + {% if perms.fileupload %} + + + {% endif %} + From 1b388e01300968ccd522d35cea3d8e342f0ce896 Mon Sep 17 00:00:00 2001 From: Fabrizio Buratta Date: Tue, 25 Feb 2014 09:51:47 +0100 Subject: [PATCH 24/57] views clean up --- fileupload/urls.py | 3 +-- fileupload/views.py | 11 ----------- 2 files changed, 1 insertion(+), 13 deletions(-) diff --git a/fileupload/urls.py b/fileupload/urls.py index 357f433..963aa68 100644 --- a/fileupload/urls.py +++ b/fileupload/urls.py @@ -2,8 +2,7 @@ from django.conf.urls import patterns, url from fileupload.views import ( - BasicVersionCreateView, BasicPlusVersionCreateView, - jQueryVersionCreateView, AngularVersionCreateView, + jQueryVersionCreateView, FileCreateView, FileDeleteView, FileListView, login_view, logout_view, ) diff --git a/fileupload/views.py b/fileupload/views.py index 92f7125..b2f61aa 100644 --- a/fileupload/views.py +++ b/fileupload/views.py @@ -42,17 +42,6 @@ def form_invalid(self, form): data = json.dumps(form.errors) return HttpResponse(content=data, status=400, content_type='application/json') -class BasicVersionCreateView(FileCreateView): - template_name_suffix = '_basic_form' - - -class BasicPlusVersionCreateView(FileCreateView): - template_name_suffix = '_basicplus_form' - - -class AngularVersionCreateView(FileCreateView): - template_name_suffix = '_angular_form' - class jQueryVersionCreateView(FileCreateView): template_name_suffix = '_jquery_form' From fed77953f4653b7bc2e72c3c4b7c46c0a20ead14 Mon Sep 17 00:00:00 2001 From: Fabrizio Buratta Date: Tue, 25 Feb 2014 16:01:36 +0100 Subject: [PATCH 25/57] added email notification on upload --- fileupload/views.py | 30 ++++++++++++++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-) diff --git a/fileupload/views.py b/fileupload/views.py index b2f61aa..ded5690 100644 --- a/fileupload/views.py +++ b/fileupload/views.py @@ -9,6 +9,33 @@ from django.contrib.auth import authenticate, login from django.contrib.auth import logout from django.shortcuts import redirect +import smtplib + +def send_email(response,user): + + FROMADDR = "uploads@ml.moldiscovery.com" + LOGIN = FROMADDR + #PASSWORD = "" + TOADDRS = ["fabrizio@moldiscovery.com"] + SUBJECT = "Files uploaded" + msg_content = "User: %s \r\n" % user + + for file in response['files']: + msg_content += "File Uploaded: "+ file['name'] + '\r\n' + msg_content += "Download: https://ml.moldiscovery.com"+ file['url'] + '\r\n\r\n' + + msg = ("From: %s\r\nTo: %s\r\nSubject: %s\r\n\r\n" + % (FROMADDR, ", ".join(TOADDRS), SUBJECT) ) + msg += msg_content+"\r\n" + + server = smtplib.SMTP('localhost', 25) + #server.set_debuglevel(1) + server.ehlo("ml.moldiscovery.com") + #server.starttls() + #server.login(LOGIN, PASSWORD) + server.sendmail(FROMADDR, TOADDRS, msg) + server.quit() + def logout_view(request): logout(request) @@ -25,8 +52,6 @@ def login_view(request): return redirect('home') - - class FileCreateView(CreateView): model = File @@ -36,6 +61,7 @@ def form_valid(self, form): data = {'files': files} response = JSONResponse(data, mimetype=response_mimetype(self.request)) response['Content-Disposition'] = 'inline; filename=files.json' + send_email(data, self.request.user.username) return response def form_invalid(self, form): From fc18e98ccc0b301e46466d2a3b816b5fc66454d2 Mon Sep 17 00:00:00 2001 From: Fabrizio Buratta Date: Thu, 27 Feb 2014 17:49:41 +0100 Subject: [PATCH 26/57] minimum file size upload to 5MB --- .../static/js/jquery.fileupload-validate.js | 2 +- fileupload/static/js/locale.js | 2 +- fileupload/static/js/main.js | 58 ++++++------------- 3 files changed, 19 insertions(+), 43 deletions(-) diff --git a/fileupload/static/js/jquery.fileupload-validate.js b/fileupload/static/js/jquery.fileupload-validate.js index ee1c2f2..62f9fd3 100644 --- a/fileupload/static/js/jquery.fileupload-validate.js +++ b/fileupload/static/js/jquery.fileupload-validate.js @@ -71,7 +71,7 @@ maxNumberOfFiles: 'Maximum number of files exceeded', acceptFileTypes: 'File type not allowed', maxFileSize: 'File is too large', - minFileSize: 'File is too small' + minFileSize: 'File is too small, min allowed size is 5MB.' } }, diff --git a/fileupload/static/js/locale.js b/fileupload/static/js/locale.js index ea64b0a..3375080 100644 --- a/fileupload/static/js/locale.js +++ b/fileupload/static/js/locale.js @@ -15,7 +15,7 @@ window.locale = { "fileupload": { "errors": { "maxFileSize": "File is too big", - "minFileSize": "File is too small", + "minFileSize": "File is too small, minumum size is 5MB.", "acceptFileTypes": "Filetype not allowed", "maxNumberOfFiles": "Max number of files exceeded", "uploadedBytes": "Uploaded bytes exceed file size", diff --git a/fileupload/static/js/main.js b/fileupload/static/js/main.js index 1850909..049c3f1 100644 --- a/fileupload/static/js/main.js +++ b/fileupload/static/js/main.js @@ -17,6 +17,8 @@ $(function () { // Initialize the jQuery File Upload widget: $('#fileupload').fileupload({ + + minFileSize: 5000000, // Uncomment the following to send cross-domain cookies: //xhrFields: {withCredentials: true}, //url: 'server/php/' @@ -32,46 +34,20 @@ $(function () { ) ); - if (window.location.hostname === 'blueimp.github.io') { - // Demo settings: - $('#fileupload').fileupload('option', { - url: '//jquery-file-upload.appspot.com/', - // Enable image resizing, except for Android and Opera, - // which actually support image resizing, but fail to - // send Blob objects via XHR requests: - disableImageResize: /Android(?!.*Chrome)|Opera/ - .test(window.navigator.userAgent), - maxFileSize: 5000000, - acceptFileTypes: /(\.|\/)(gif|jpe?g|png)$/i - }); - // Upload server status check for browsers with CORS support: - if ($.support.cors) { - $.ajax({ - url: '//jquery-file-upload.appspot.com/', - type: 'HEAD' - }).fail(function () { - $('
') - .text('Upload server currently unavailable - ' + - new Date()) - .appendTo('#fileupload'); - }); - } - } else { - // Load existing files: - $('#fileupload').addClass('fileupload-processing'); - $.ajax({ - // Uncomment the following to send cross-domain cookies: - //xhrFields: {withCredentials: true}, - //url: $('#fileupload').fileupload('option', 'url'), - url: '/upload/view/', - dataType: 'json', - context: $('#fileupload')[0] - }).always(function () { - $(this).removeClass('fileupload-processing'); - }).done(function (result) { - $(this).fileupload('option', 'done') - .call(this, null, {result: result}); - }); - } + // Load existing files: + $('#fileupload').addClass('fileupload-processing'); + $.ajax({ + // Uncomment the following to send cross-domain cookies: + //xhrFields: {withCredentials: true}, + //url: $('#fileupload').fileupload('option', 'url'), + url: '/upload/view/', + dataType: 'json', + context: $('#fileupload')[0] + }).always(function () { + $(this).removeClass('fileupload-processing'); + }).done(function (result) { + $(this).fileupload('option', 'done') + .call(this, null, {result: result}); + }); }); From a3a9cdc06fdd9a75746fe3372f6eab7e74ca91d0 Mon Sep 17 00:00:00 2001 From: Fabrizio Buratta Date: Thu, 27 Feb 2014 17:50:49 +0100 Subject: [PATCH 27/57] security fix: view/create/delete only for logged in users --- fileupload/views.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/fileupload/views.py b/fileupload/views.py index ded5690..1320538 100644 --- a/fileupload/views.py +++ b/fileupload/views.py @@ -56,6 +56,9 @@ class FileCreateView(CreateView): model = File def form_valid(self, form): + if not self.request.user.is_authenticated(): + return redirect('home') + self.object = form.save() files = [serialize(self.object)] data = {'files': files} @@ -77,6 +80,9 @@ class FileDeleteView(DeleteView): model = File def delete(self, request, *args, **kwargs): + if not self.request.user.is_authenticated(): + return redirect('home') + self.object = self.get_object() self.object.delete() response = JSONResponse(True, mimetype=response_mimetype(request)) @@ -91,6 +97,10 @@ def get_queryset(self): return File.objects.filter(username=self.request.user) def render_to_response(self, context, **response_kwargs): + + if not self.request.user.is_authenticated(): + return redirect('home') + files = [ serialize(p) for p in self.get_queryset() ] data = {'files': files} response = JSONResponse(data, mimetype=response_mimetype(self.request)) From a347c57443a6b657d3820dc4b5998d01a44c9dc7 Mon Sep 17 00:00:00 2001 From: root Date: Thu, 27 Feb 2014 18:23:13 +0100 Subject: [PATCH 28/57] minor --- fileupload/views.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fileupload/views.py b/fileupload/views.py index 1320538..7974458 100644 --- a/fileupload/views.py +++ b/fileupload/views.py @@ -22,7 +22,7 @@ def send_email(response,user): for file in response['files']: msg_content += "File Uploaded: "+ file['name'] + '\r\n' - msg_content += "Download: https://ml.moldiscovery.com"+ file['url'] + '\r\n\r\n' + msg_content += "Download: https://ml.moldiscovery.com:8888/uploader"+ file['url'] + '\r\n\r\n' msg = ("From: %s\r\nTo: %s\r\nSubject: %s\r\n\r\n" % (FROMADDR, ", ".join(TOADDRS), SUBJECT) ) From bde0195d558f4021cb36013ba8f7c2f841866193 Mon Sep 17 00:00:00 2001 From: Fabrizio Buratta Date: Fri, 28 Feb 2014 11:10:42 +0100 Subject: [PATCH 29/57] better progress bar css --- fileupload/static/css/jquery.fileupload-ui.css | 9 +++++++++ fileupload/views.py | 1 + 2 files changed, 10 insertions(+) diff --git a/fileupload/static/css/jquery.fileupload-ui.css b/fileupload/static/css/jquery.fileupload-ui.css index fe1be75..74c080b 100644 --- a/fileupload/static/css/jquery.fileupload-ui.css +++ b/fileupload/static/css/jquery.fileupload-ui.css @@ -45,6 +45,15 @@ margin: 0px; } +.ui-widget-content { + border: 1px solid #555555; + height: 14px; + margin-bottom: 10px; + width: 80%; + background: #000000 url(../img/progessbar.gif) 50% 50% repeat; + color: #ffffff; +} + .ui-widget { font-size: 0.92em; } diff --git a/fileupload/views.py b/fileupload/views.py index 7974458..7fb24a4 100644 --- a/fileupload/views.py +++ b/fileupload/views.py @@ -22,6 +22,7 @@ def send_email(response,user): for file in response['files']: msg_content += "File Uploaded: "+ file['name'] + '\r\n' + msg_content += "File Size: "+ str(file['size']) + ' bytes\r\n' msg_content += "Download: https://ml.moldiscovery.com:8888/uploader"+ file['url'] + '\r\n\r\n' msg = ("From: %s\r\nTo: %s\r\nSubject: %s\r\n\r\n" From dcb92d5962027f8623498836dba4b920e585cc98 Mon Sep 17 00:00:00 2001 From: Fabrizio Buratta Date: Fri, 28 Feb 2014 12:09:51 +0100 Subject: [PATCH 30/57] better progress bar image --- fileupload/static/css/jquery.fileupload-ui.css | 10 +++++++++- .../img/ui-bg_highlight-soft_44_444444_1x100.png | Bin 0 -> 215 bytes .../ui-bg_highlight-soft_44_444444_1x100.png.orig | Bin 0 -> 277 bytes 3 files changed, 9 insertions(+), 1 deletion(-) create mode 100644 fileupload/static/img/ui-bg_highlight-soft_44_444444_1x100.png create mode 100644 fileupload/static/img/ui-bg_highlight-soft_44_444444_1x100.png.orig diff --git a/fileupload/static/css/jquery.fileupload-ui.css b/fileupload/static/css/jquery.fileupload-ui.css index 74c080b..0139638 100644 --- a/fileupload/static/css/jquery.fileupload-ui.css +++ b/fileupload/static/css/jquery.fileupload-ui.css @@ -50,10 +50,18 @@ height: 14px; margin-bottom: 10px; width: 80%; - background: #000000 url(../img/progessbar.gif) 50% 50% repeat; + background: #000000 url(../img/progressbar.gif) 50% 50% repeat; color: #ffffff; } +.ui-widget-header { +border: 1px solid #005491; +/*background: #388532 url(images/ui-bg_highlight-soft_44_444444_1x100.png) 50% 50% repeat-x;*/ +background: #005491 url(../img/ui-bg_highlight-soft_44_444444_1x100.png) 50% 50% repeat-x; +color: #ffffff; +font-weight: bold; +} + .ui-widget { font-size: 0.92em; } diff --git a/fileupload/static/img/ui-bg_highlight-soft_44_444444_1x100.png b/fileupload/static/img/ui-bg_highlight-soft_44_444444_1x100.png new file mode 100644 index 0000000000000000000000000000000000000000..32733d6562e7cfb240383386f5447c0e82acd354 GIT binary patch literal 215 zcmeAS@N?(olHy`uVBq!ia0vp^j6j^i!2~2v_?0{X??Smc!zY2lH!<>7kwzRU zHT&$XW`1Z%vYKJFj7M!@&7(H<+kX5tJnJ)9}fO~aQ^MPw(0M>1HQ4I{V1~6{m}fUKo>B0 My85}Sb4q9e08yw`lK=n! literal 0 HcmV?d00001 diff --git a/fileupload/static/img/ui-bg_highlight-soft_44_444444_1x100.png.orig b/fileupload/static/img/ui-bg_highlight-soft_44_444444_1x100.png.orig new file mode 100644 index 0000000000000000000000000000000000000000..a4e5b22e29f505535f92343e9b95e90c2b2c6460 GIT binary patch literal 277 zcmeAS@N?(olHy`uVBq!ia0vp^j6j?s03;ZUuHXC*q?nSt-Ch3w7g=q17Rci)@Q5r1 z(jH*!b~4)z$O!jzaSV~ToUF0;kc0Y_69IoZ7M_^7FhSG#URv9nnl>HXwlC>CE9-bX zZ%Yb^NF-THEV46laWQInX3Uap%;J;w;dA<&;$VFLsfnN literal 0 HcmV?d00001 From 04b511e61dc33ac54f15d2f75e98db3d48571ab9 Mon Sep 17 00:00:00 2001 From: Fabrizio Buratta Date: Fri, 28 Feb 2014 12:19:17 +0100 Subject: [PATCH 31/57] minor --- fileupload/static/css/jquery.fileupload-ui.css | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fileupload/static/css/jquery.fileupload-ui.css b/fileupload/static/css/jquery.fileupload-ui.css index 0139638..b52a3af 100644 --- a/fileupload/static/css/jquery.fileupload-ui.css +++ b/fileupload/static/css/jquery.fileupload-ui.css @@ -55,7 +55,7 @@ } .ui-widget-header { -border: 1px solid #005491; +border: 1px solid #020091; /*background: #388532 url(images/ui-bg_highlight-soft_44_444444_1x100.png) 50% 50% repeat-x;*/ background: #005491 url(../img/ui-bg_highlight-soft_44_444444_1x100.png) 50% 50% repeat-x; color: #ffffff; From df1e8ab617858e8c67ee91e157478e73898597ea Mon Sep 17 00:00:00 2001 From: Fabrizio Buratta Date: Fri, 28 Feb 2014 12:24:29 +0100 Subject: [PATCH 32/57] minor --- fileupload/static/css/jquery.fileupload-ui.css | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fileupload/static/css/jquery.fileupload-ui.css b/fileupload/static/css/jquery.fileupload-ui.css index b52a3af..760f027 100644 --- a/fileupload/static/css/jquery.fileupload-ui.css +++ b/fileupload/static/css/jquery.fileupload-ui.css @@ -55,7 +55,7 @@ } .ui-widget-header { -border: 1px solid #020091; +border: 1px solid #798E9B; /*background: #388532 url(images/ui-bg_highlight-soft_44_444444_1x100.png) 50% 50% repeat-x;*/ background: #005491 url(../img/ui-bg_highlight-soft_44_444444_1x100.png) 50% 50% repeat-x; color: #ffffff; From e4db8679a7500c51f19abc117b36337d0e06b4e5 Mon Sep 17 00:00:00 2001 From: Fabrizio Buratta Date: Fri, 28 Feb 2014 13:02:27 +0100 Subject: [PATCH 33/57] compress files TIP --- fileupload/templates/fileupload/file_jquery_form.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fileupload/templates/fileupload/file_jquery_form.html b/fileupload/templates/fileupload/file_jquery_form.html index d4516ad..b190ed6 100644 --- a/fileupload/templates/fileupload/file_jquery_form.html +++ b/fileupload/templates/fileupload/file_jquery_form.html @@ -50,7 +50,7 @@
- +

Molecular Discovery Secure File Upload.

Molecular Discovery Secure File Upload.


( TIP: Compress your files when possible. )

From d3eaf40d11fa529a9a12b65f0a8e1b59942fda51 Mon Sep 17 00:00:00 2001 From: Bobo Date: Tue, 18 Mar 2014 15:47:39 +0100 Subject: [PATCH 34/57] added action to download selected files --- fileupload/admin.py | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/fileupload/admin.py b/fileupload/admin.py index 8b5ec66..a83b6c6 100644 --- a/fileupload/admin.py +++ b/fileupload/admin.py @@ -1,4 +1,24 @@ from fileupload.models import File from django.contrib import admin +from django.http import HttpResponse +import tarfile -admin.site.register(File) +def make_download(modeladmin, request, queryset): + response = HttpResponse(mimetype='application/x-gzip') + response['Content-Disposition'] = 'attachment; filename=MD_secure_upload_download.tar.gz' + tarred = tarfile.open(fileobj=response, mode='w:gz') + + for file in queryset: + tarred.add("media/"+file.file.name) + tarred.close() + + return response + +make_download.short_description = "Download selected files" + + +class FileAdmin(admin.ModelAdmin): + actions = [make_download] + + +admin.site.register(File,FileAdmin) From fe0a01dfeda15e0d869ba536b48a41942fcc8227 Mon Sep 17 00:00:00 2001 From: Bobo Date: Tue, 18 Mar 2014 16:34:13 +0100 Subject: [PATCH 35/57] added maxsize to multiple downloads --- fileupload/admin.py | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/fileupload/admin.py b/fileupload/admin.py index a83b6c6..f23a7b7 100644 --- a/fileupload/admin.py +++ b/fileupload/admin.py @@ -2,17 +2,33 @@ from django.contrib import admin from django.http import HttpResponse import tarfile +from django.contrib import messages +def validate_size(files, maxsize): + total_size = 0 + if len(files) > 1: + for file in files: + total_size += file.file.size + + return total_size <= maxsize + return True + def make_download(modeladmin, request, queryset): response = HttpResponse(mimetype='application/x-gzip') response['Content-Disposition'] = 'attachment; filename=MD_secure_upload_download.tar.gz' tarred = tarfile.open(fileobj=response, mode='w:gz') - for file in queryset: - tarred.add("media/"+file.file.name) - tarred.close() + + if not validate_size(queryset,500000000): + messages.warning(request, "Download is too big, unselect some files, max size = 500 MB") + + else: + + for file in queryset: + tarred.add("media/"+file.file.name) + tarred.close() - return response + return response make_download.short_description = "Download selected files" From ac561376377552d3a6c0b510b47dcd6089cb44ac Mon Sep 17 00:00:00 2001 From: Bobo Date: Tue, 18 Mar 2014 16:42:32 +0100 Subject: [PATCH 36/57] minor --- fileupload/admin.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fileupload/admin.py b/fileupload/admin.py index f23a7b7..b156d69 100644 --- a/fileupload/admin.py +++ b/fileupload/admin.py @@ -20,7 +20,7 @@ def make_download(modeladmin, request, queryset): if not validate_size(queryset,500000000): - messages.warning(request, "Download is too big, unselect some files, max size = 500 MB") + messages.warning(request, "Download group is too big, unselect some files or select just 1, max size of multple download: 500 MB") else: From 25f900e1279ea47ebc39bc898926017e25fa16ed Mon Sep 17 00:00:00 2001 From: Bobo Date: Tue, 18 Mar 2014 17:18:06 +0100 Subject: [PATCH 37/57] ordered Fileadmin and verbose slug --- fileupload/admin.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/fileupload/admin.py b/fileupload/admin.py index b156d69..c98b217 100644 --- a/fileupload/admin.py +++ b/fileupload/admin.py @@ -32,8 +32,15 @@ def make_download(modeladmin, request, queryset): make_download.short_description = "Download selected files" +def file_size(obj): + if obj.file.size < 1000000: + return ("%s bytes" % (obj.file.size)) + return ("%s MBs" % (obj.file.size/1000000)) +file_size.short_description = 'Size' class FileAdmin(admin.ModelAdmin): + list_display = ('slug','username', file_size) + ordering = ('username','slug') actions = [make_download] From f8cbcfc904b18d6b79488dc86f8241afb99d4a7f Mon Sep 17 00:00:00 2001 From: Bobo Date: Tue, 18 Mar 2014 17:57:20 +0100 Subject: [PATCH 38/57] added verbose name to slug --- fileupload/models.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fileupload/models.py b/fileupload/models.py index 27b8210..9a09f77 100644 --- a/fileupload/models.py +++ b/fileupload/models.py @@ -12,7 +12,7 @@ class File(models.Model): """ file = models.FileField(upload_to=upload_dir_path) - slug = models.SlugField(max_length=50, blank=True ) + slug = models.SlugField(max_length=50, blank=True, verbose_name="file name") username = models.CharField(max_length=50) def __unicode__(self): From b10c3af77ee4cc04ba37250340d680f33fb2f751 Mon Sep 17 00:00:00 2001 From: Bobo Date: Wed, 19 Mar 2014 10:43:50 +0100 Subject: [PATCH 39/57] use MEDIA_ROOT when tarring files --- fileupload/admin.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/fileupload/admin.py b/fileupload/admin.py index c98b217..b48304e 100644 --- a/fileupload/admin.py +++ b/fileupload/admin.py @@ -3,6 +3,7 @@ from django.http import HttpResponse import tarfile from django.contrib import messages +from django.conf import settings def validate_size(files, maxsize): total_size = 0 @@ -25,7 +26,7 @@ def make_download(modeladmin, request, queryset): else: for file in queryset: - tarred.add("media/"+file.file.name) + tarred.add(settings.MEDIA_ROOT+file.file.name, arcname=file.file.name ) tarred.close() return response From 474a9403e251ac3ce13fb68c0b42119d0c5e3360 Mon Sep 17 00:00:00 2001 From: Bobo Date: Wed, 19 Mar 2014 11:03:30 +0100 Subject: [PATCH 40/57] added error messages --- fileupload/admin.py | 32 ++++++++++++++++++++------------ 1 file changed, 20 insertions(+), 12 deletions(-) diff --git a/fileupload/admin.py b/fileupload/admin.py index b48304e..f5bc347 100644 --- a/fileupload/admin.py +++ b/fileupload/admin.py @@ -15,21 +15,29 @@ def validate_size(files, maxsize): return True def make_download(modeladmin, request, queryset): - response = HttpResponse(mimetype='application/x-gzip') - response['Content-Disposition'] = 'attachment; filename=MD_secure_upload_download.tar.gz' - tarred = tarfile.open(fileobj=response, mode='w:gz') - - if not validate_size(queryset,500000000): - messages.warning(request, "Download group is too big, unselect some files or select just 1, max size of multple download: 500 MB") + try: + response = HttpResponse(mimetype='application/x-gzip') + response['Content-Disposition'] = 'attachment; filename=MD_secure_upload_download.tar.gz' + tarred = tarfile.open(fileobj=response, mode='w:gz') - else: - - for file in queryset: - tarred.add(settings.MEDIA_ROOT+file.file.name, arcname=file.file.name ) - tarred.close() - return response + if not validate_size(queryset,500000000): + messages.warning(request, "Download group is too big, unselect some files or select just 1, max size of multple download: 500 MB") + + else: + + for file in queryset: + tarred.add(settings.MEDIA_ROOT+file.file.name, arcname=file.file.name ) + tarred.close() + + return response + + except tarfile.TarError: + messages.error(request, "Error while creating the TAR archive, contact the webmaster.") + except : + messages.error(request, "There was an error, please contact the webmaster") + make_download.short_description = "Download selected files" From 73738d510a77f70c8ae7338c0dff7c9a63ff88d8 Mon Sep 17 00:00:00 2001 From: root Date: Thu, 10 Dec 2015 11:15:02 +0100 Subject: [PATCH 41/57] bunch of commits which are fixes and improvements on production --- fileupload/admin.py | 1 + fileupload/static/img/MD_logo.png | Bin 12778 -> 6278 bytes fileupload/static/js/app.js | 2 +- .../static/js/jquery.fileupload-validate.js | 2 +- fileupload/static/js/main.js | 4 ++-- fileupload/views.py | 2 +- settings.py | 8 ++++++-- 7 files changed, 12 insertions(+), 7 deletions(-) diff --git a/fileupload/admin.py b/fileupload/admin.py index f5bc347..3ae5990 100644 --- a/fileupload/admin.py +++ b/fileupload/admin.py @@ -49,6 +49,7 @@ def file_size(obj): class FileAdmin(admin.ModelAdmin): list_display = ('slug','username', file_size) + search_fields = ['slug', 'username'] ordering = ('username','slug') actions = [make_download] diff --git a/fileupload/static/img/MD_logo.png b/fileupload/static/img/MD_logo.png index 257bd14423a50c22bb2cb0c09fa81b1ad79c658a..47b3350a5b1f485b4e96f178f0f8ecebee680aa0 100644 GIT binary patch literal 6278 zcmV;17<1^@s6l;`V?00006VoOIv0RI60 z0RN!9r;`8x010qNS#tmY3ljhU3ljkVnw%H_000McNliru-wX-~6(END^lShC7!yfE zK~#9!?VWj?U(?;k-!qd*B58_@R zD@X0BC91YlAxag^RB#XzYb*)b_nGI9^SK;9znMf#ruy`LU$5V5?%aFsS-;=&-OsI| z8^Kt&EbvEQ2(Ww%eljJL@Fj-YZfMK&|mHS4;ZkP^PsP}9xC zu>|lVU`gPYG5ERV5|r>|h92GAUK4PdM6LUPf0Rp5LP;Q>z(0Vyfd0S><@A^EA4wp_ zI%4n`>uM#&&5ywY%mR*3v9?SPsm<@HYzZa&%b~Wb2qK3J!S?|!;}eV3VBqh-JHS%9 z*9SNZ_!-c*8gZ1$d<6CIf2#X8;3% zTY+)Lx}Ly>z%*b?41Qj@R3-e|aF7mm^joA~?3&#>8W;xLsQLY_!SlYl9HR0@TDM-YKUm8`&hrI0xtqnB|a5!qeQ7K^nVSoF|c`7e;aUH z4F2R8{0!Zj4!ohdrdQ!spXpyoI3+9&SfC%oShqT`7I1G2ewyy}2QC7(1h$UBk2Tiy z1$s$rYKy_Q8|w}g7Z?Yu4;XQp6@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Bm#E|FwYP;KPYixv2AFO}XWH1AZt; z)U)xSH_MK#joO@*Qf5LkTMaAK-GHIF3T~uF$%`=AdC>*gM$a#smM6M6+_ADq?CykK z8U_H(>VzHJy#~YA|DaN^!IA(9N!_}+insuu7sIc7I^P)#GaI%ugBh8n2^oaH%jg#|hb0QrXiB6nujB<$f&~`3h5!Hn diff --git a/fileupload/static/js/app.js b/fileupload/static/js/app.js index 729eb1a..404b13d 100644 --- a/fileupload/static/js/app.js +++ b/fileupload/static/js/app.js @@ -40,7 +40,7 @@ // send Blob objects via XHR requests: disableImageResize: /Android(?!.*Chrome)|Opera/ .test(window.navigator.userAgent), - maxFileSize: 5000000, + maxFileSize: 100000, acceptFileTypes: /(\.|\/)(gif|jpe?g|png)$/i }); } diff --git a/fileupload/static/js/jquery.fileupload-validate.js b/fileupload/static/js/jquery.fileupload-validate.js index 62f9fd3..de37447 100644 --- a/fileupload/static/js/jquery.fileupload-validate.js +++ b/fileupload/static/js/jquery.fileupload-validate.js @@ -71,7 +71,7 @@ maxNumberOfFiles: 'Maximum number of files exceeded', acceptFileTypes: 'File type not allowed', maxFileSize: 'File is too large', - minFileSize: 'File is too small, min allowed size is 5MB.' + minFileSize: 'File is too small, min allowed size is 0.1MB.' } }, diff --git a/fileupload/static/js/main.js b/fileupload/static/js/main.js index 049c3f1..47d960a 100644 --- a/fileupload/static/js/main.js +++ b/fileupload/static/js/main.js @@ -18,7 +18,7 @@ $(function () { // Initialize the jQuery File Upload widget: $('#fileupload').fileupload({ - minFileSize: 5000000, + minFileSize: 100000, // Uncomment the following to send cross-domain cookies: //xhrFields: {withCredentials: true}, //url: 'server/php/' @@ -40,7 +40,7 @@ $(function () { // Uncomment the following to send cross-domain cookies: //xhrFields: {withCredentials: true}, //url: $('#fileupload').fileupload('option', 'url'), - url: '/upload/view/', + url: 'https://ml.moldiscovery.com:8888/uploader/upload/view/', dataType: 'json', context: $('#fileupload')[0] }).always(function () { diff --git a/fileupload/views.py b/fileupload/views.py index 7fb24a4..cf799f6 100644 --- a/fileupload/views.py +++ b/fileupload/views.py @@ -65,7 +65,7 @@ def form_valid(self, form): data = {'files': files} response = JSONResponse(data, mimetype=response_mimetype(self.request)) response['Content-Disposition'] = 'inline; filename=files.json' - send_email(data, self.request.user.username) + #send_email(data, self.request.user.username) return response def form_invalid(self, form): diff --git a/settings.py b/settings.py index 4328f30..390e6c3 100644 --- a/settings.py +++ b/settings.py @@ -1,12 +1,16 @@ import os -DEBUG = True +DEBUG = False TEMPLATE_DEBUG = DEBUG +ALLOWED_HOSTS = ['ml.moldiscovery.com','fileserver.lan','ajax.googleapis.com'] + SITE_ROOT = os.path.dirname(os.path.realpath(__file__)) +SERVER_EMAIL = 'admin@ml.moldiscovery.com' + ADMINS = ( - # ('Your Name', 'your_email@example.com'), + ('SysAdmin', 'fabrizio@moldiscovery.com'), ) MANAGERS = ADMINS From 5bf157ef5020a4bdc4c6b3f6aa373405c8e355b8 Mon Sep 17 00:00:00 2001 From: fburatta Date: Fri, 15 Jan 2016 10:38:46 +0100 Subject: [PATCH 42/57] added last modified --- fileupload/admin.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/fileupload/admin.py b/fileupload/admin.py index 3ae5990..42a8847 100644 --- a/fileupload/admin.py +++ b/fileupload/admin.py @@ -4,6 +4,7 @@ import tarfile from django.contrib import messages from django.conf import settings +import os.path, time def validate_size(files, maxsize): total_size = 0 @@ -47,8 +48,12 @@ def file_size(obj): return ("%s MBs" % (obj.file.size/1000000)) file_size.short_description = 'Size' +def last_modified(obj): + date_text = "%s" % time.ctime(os.path.getmtime(settings.MEDIA_ROOT+obj.file.name)) + return date_text + class FileAdmin(admin.ModelAdmin): - list_display = ('slug','username', file_size) + list_display = ('slug','username', file_size, last_modified) search_fields = ['slug', 'username'] ordering = ('username','slug') actions = [make_download] From 2ee84804094ba7986b2862e3f86aa59276e3c706 Mon Sep 17 00:00:00 2001 From: fburatta Date: Thu, 26 May 2016 08:31:43 +0200 Subject: [PATCH 43/57] manage script update --- manage.py | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/manage.py b/manage.py index 3e4eedc..f9726f9 100755 --- a/manage.py +++ b/manage.py @@ -1,14 +1,10 @@ #!/usr/bin/env python -from django.core.management import execute_manager -import imp -try: - imp.find_module('settings') # Assumed to be in the same directory. -except ImportError: - import sys - sys.stderr.write("Error: Can't find the file 'settings.py' in the directory containing %r. It appears you've customized things.\nYou'll have to run django-admin.py, passing it your settings module.\n" % __file__) - sys.exit(1) - -import settings +import os +import sys if __name__ == "__main__": - execute_manager(settings) + os.environ.setdefault("DJANGO_SETTINGS_MODULE", "settings") + + from django.core.management import execute_from_command_line + + execute_from_command_line(sys.argv) From 874c41ca1c211f474fb58658d46cb8524fd20cfb Mon Sep 17 00:00:00 2001 From: fburatta Date: Thu, 26 May 2016 09:41:21 +0200 Subject: [PATCH 44/57] archive files action added --- fileupload/admin.py | 27 +++++++- settings.py | 16 +++-- settings_dev.py | 159 ++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 197 insertions(+), 5 deletions(-) create mode 100644 settings_dev.py diff --git a/fileupload/admin.py b/fileupload/admin.py index 42a8847..3504d2e 100644 --- a/fileupload/admin.py +++ b/fileupload/admin.py @@ -2,6 +2,7 @@ from django.contrib import admin from django.http import HttpResponse import tarfile +import shutil from django.contrib import messages from django.conf import settings import os.path, time @@ -42,6 +43,30 @@ def make_download(modeladmin, request, queryset): make_download.short_description = "Download selected files" + +def make_archive(modeladmin, request, queryset): + + try: + + for file in queryset: + archive_dir = os.path.join(settings.ARCHIVE_ROOT,file.username) + if not os.path.exists(archive_dir): + os.makedirs(archive_dir) + + shutil.copyfile(settings.MEDIA_ROOT+file.file.name, os.path.join(archive_dir,file.slug)) + + file.delete() + + messages.info(request, file.slug + " Archived Successfully") + + except shutil.Error: + messages.error(request, "File Copy error, please contact the webmaster") + except : + messages.error(request, "There was an error, please contact the webmaster") + +make_archive.short_description = "Archive selected files" + + def file_size(obj): if obj.file.size < 1000000: return ("%s bytes" % (obj.file.size)) @@ -56,7 +81,7 @@ class FileAdmin(admin.ModelAdmin): list_display = ('slug','username', file_size, last_modified) search_fields = ['slug', 'username'] ordering = ('username','slug') - actions = [make_download] + actions = [make_download,make_archive] admin.site.register(File,FileAdmin) diff --git a/settings.py b/settings.py index 390e6c3..5482b95 100644 --- a/settings.py +++ b/settings.py @@ -58,6 +58,8 @@ # Examples: "http://media.lawrence.com/media/", "http://example.com/media/" MEDIA_URL = '/media/' +ARCHIVE_ROOT = os.path.join(MEDIA_ROOT,'archived') + # Absolute path to the directory static files should be collected to. # Don't put anything in this directory yourself; store your static files # in apps' "static/" subdirectories and in STATICFILES_DIRS. @@ -137,11 +139,17 @@ 'version': 1, 'disable_existing_loggers': False, 'handlers': { - 'mail_admins': { - 'level': 'ERROR', - 'class': 'django.utils.log.AdminEmailHandler' + 'mail_admins': { + 'level': 'ERROR', + 'filters': ['require_debug_false'], + 'class': 'django.utils.log.AdminEmailHandler' } }, + 'filters': { + 'require_debug_false': { + '()': 'django.utils.log.RequireDebugFalse' + } + }, 'loggers': { 'django.request': { 'handlers': ['mail_admins'], @@ -149,4 +157,4 @@ 'propagate': True, }, } -} +} \ No newline at end of file diff --git a/settings_dev.py b/settings_dev.py new file mode 100644 index 0000000..23fdb0c --- /dev/null +++ b/settings_dev.py @@ -0,0 +1,159 @@ +import os + +DEBUG = True +TEMPLATE_DEBUG = DEBUG + +# uncomment this on production server and DEBUG=False +#ALLOWED_HOSTS = ['ml.moldiscovery.com','ajax.googleapis.com'] + +SITE_ROOT = os.path.dirname(os.path.realpath(__file__)) + +ADMINS = ( + ('Fabrizio Buratta', 'fabrizio@moldiscovery.com'), +) + +MANAGERS = ADMINS + +DATABASES = { + 'default': { + 'ENGINE': 'django.db.backends.sqlite3', # Add 'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'oracle'. + 'NAME': os.path.join(SITE_ROOT, 'db'), # Or path to database file if using sqlite3. + 'USER': '', # Not used with sqlite3. + 'PASSWORD': '', # Not used with sqlite3. + 'HOST': '', # Set to empty string for localhost. Not used with sqlite3. + 'PORT': '', # Set to empty string for default. Not used with sqlite3. + } +} + +# Local time zone for this installation. Choices can be found here: +# http://en.wikipedia.org/wiki/List_of_tz_zones_by_name +# although not all choices may be available on all operating systems. +# On Unix systems, a value of None will cause Django to use the same +# timezone as the operating system. +# If running in a Windows environment this must be set to the same as your +# system time zone. +TIME_ZONE = 'Europe/Rome' + +# Language code for this installation. All choices can be found here: +# http://www.i18nguy.com/unicode/language-identifiers.html +LANGUAGE_CODE = 'en-us' + +SITE_ID = 1 + +# If you set this to False, Django will make some optimizations so as not +# to load the internationalization machinery. +USE_I18N = True + +# If you set this to False, Django will not format dates, numbers and +# calendars according to the current locale +USE_L10N = True + +# Absolute filesystem path to the directory that will hold user-uploaded files. +# Example: "/home/media/media.lawrence.com/media/" +MEDIA_ROOT = os.path.abspath(os.path.dirname(__file__)) + '/media/' + +ARCHIVE_ROOT = os.path.join(MEDIA_ROOT,'archived') + +# URL that handles the media served from MEDIA_ROOT. Make sure to use a +# trailing slash. +# Examples: "http://media.lawrence.com/media/", "http://example.com/media/" +MEDIA_URL = '/media/' + +# Absolute path to the directory static files should be collected to. +# Don't put anything in this directory yourself; store your static files +# in apps' "static/" subdirectories and in STATICFILES_DIRS. +# Example: "/home/media/media.lawrence.com/static/" +STATIC_ROOT = os.path.abspath(os.path.dirname(__file__)) + '/static/' + +# URL prefix for static files. +# Example: "http://media.lawrence.com/static/" +STATIC_URL = '/static/' + +# URL prefix for admin static files -- CSS, JavaScript and images. +# Make sure to use a trailing slash. +# Examples: "http://foo.com/static/admin/", "/static/admin/". +ADMIN_MEDIA_PREFIX = '/static/admin/' + +# Additional locations of static files +STATICFILES_DIRS = ( + # Put strings here, like "/home/html/static" or "C:/www/django/static". + # Always use forward slashes, even on Windows. + # Don't forget to use absolute paths, not relative paths. +) + +# List of finder classes that know how to find static files in +# various locations. +STATICFILES_FINDERS = ( + 'django.contrib.staticfiles.finders.FileSystemFinder', + 'django.contrib.staticfiles.finders.AppDirectoriesFinder', +# 'django.contrib.staticfiles.finders.DefaultStorageFinder', +) + +# Make this unique, and don't share it with anybody. +SECRET_KEY = '9%$in^gpdaig@v3or_to&_z(=n)3)$f1mr3hf9e#kespy2ajlo' + +# List of callables that know how to import templates from various sources. +TEMPLATE_LOADERS = ( + 'django.template.loaders.filesystem.Loader', + 'django.template.loaders.app_directories.Loader', +# 'django.template.loaders.eggs.Loader', +) + +MIDDLEWARE_CLASSES = ( + 'django.middleware.common.CommonMiddleware', + 'django.contrib.sessions.middleware.SessionMiddleware', + 'django.middleware.csrf.CsrfViewMiddleware', + 'django.contrib.auth.middleware.AuthenticationMiddleware', + 'django.contrib.messages.middleware.MessageMiddleware', +) + +ROOT_URLCONF = 'urls' + +TEMPLATE_DIRS = ( + # Put strings here, like "/home/html/django_templates" or "C:/www/django/templates". + # Always use forward slashes, even on Windows. + # Don't forget to use absolute paths, not relative paths. +) + +INSTALLED_APPS = ( + 'django.contrib.auth', + 'django.contrib.contenttypes', + 'django.contrib.sessions', + 'django.contrib.sites', + 'django.contrib.messages', + 'django.contrib.staticfiles', + 'fileupload', + # Uncomment the next line to enable the admin: + 'django.contrib.admin', + # Uncomment the next line to enable admin documentation: + # 'django.contrib.admindocs', +) + +# A sample logging configuration. The only tangible logging +# performed by this configuration is to send an email to +# the site admins on every HTTP 500 error. +# See http://docs.djangoproject.com/en/dev/topics/logging for +# more details on how to customize your logging configuration. +LOGGING = { + 'version': 1, + 'disable_existing_loggers': False, + 'handlers': { + 'mail_admins': { + 'level': 'ERROR', + 'filters': ['require_debug_false'], + 'class': 'django.utils.log.AdminEmailHandler' + } + }, + 'filters': { + 'require_debug_false': { + '()': 'django.utils.log.RequireDebugFalse' + } + }, + 'loggers': { + 'django.request': { + 'handlers': ['mail_admins'], + 'level': 'ERROR', + 'propagate': True, + }, + } +} From 8a106d5c82180d0c53b7f528a1d2c195229fe3bb Mon Sep 17 00:00:00 2001 From: root Date: Wed, 10 Aug 2016 12:46:08 +0000 Subject: [PATCH 45/57] added wsgi file and minor fixes --- core/wsgi.py | 58 ++++++++++++++ settings.py | 9 ++- static/css/jquery.fileupload-ui.css | 114 ++++++++++++++++++++++++++++ 3 files changed, 177 insertions(+), 4 deletions(-) create mode 100644 core/wsgi.py create mode 100644 static/css/jquery.fileupload-ui.css diff --git a/core/wsgi.py b/core/wsgi.py new file mode 100644 index 0000000..5151301 --- /dev/null +++ b/core/wsgi.py @@ -0,0 +1,58 @@ +""" +WSGI config for finto project. + +This module contains the WSGI application used by Django's development server +and any production WSGI deployments. It should expose a module-level variable +named ``application``. Django's ``runserver`` and ``runfcgi`` commands discover +this application via the ``WSGI_APPLICATION`` setting. + +Usually you will have the standard Django WSGI application here, but it also +might make sense to replace the whole Django WSGI application with a custom one +that later delegates to the Django one. For example, you could introduce WSGI +middleware here, or combine a Django application with an application of another +framework. + +""" +import os +import sys +import site + +ALLDIRS = ['/var/www/djuploader/lib/python2.7/site-packages'] + +path = '/var/www/djuploader/dj-src' +if path not in sys.path: + sys.path.append(path) + +# Remember original sys.path. +prev_sys_path = list(sys.path) + +# Add each new site-packages directory. +for directory in ALLDIRS: + site.addsitedir(directory) + +# Reorder sys.path so new directories at the front. +new_sys_path = [] +for item in list(sys.path): + if item not in prev_sys_path: + new_sys_path.append(item) + sys.path.remove(item) +sys.path[:0] = new_sys_path + +activate_this = '/var/www/djuploader/bin/activate_this.py' +execfile(activate_this, dict(__file__=activate_this)) + +# We defer to a DJANGO_SETTINGS_MODULE already in the environment. This breaks +# if running multiple sites in the same mod_wsgi process. To fix this, use +# mod_wsgi daemon mode with each site in its own daemon process, or use +# os.environ["DJANGO_SETTINGS_MODULE"] = "finto.settings" +os.environ.setdefault("DJANGO_SETTINGS_MODULE", "settings") + +# This application object is used by any WSGI server configured to use this +# file. This includes Django's development server, if the WSGI_APPLICATION +# setting points here. +from django.core.wsgi import get_wsgi_application +application = get_wsgi_application() + +# Apply WSGI middleware here. +# from helloworld.wsgi import HelloWorldApplication +# application = HelloWorldApplication(application) diff --git a/settings.py b/settings.py index 5482b95..7b0689f 100644 --- a/settings.py +++ b/settings.py @@ -3,11 +3,11 @@ DEBUG = False TEMPLATE_DEBUG = DEBUG -ALLOWED_HOSTS = ['ml.moldiscovery.com','fileserver.lan','ajax.googleapis.com'] +ALLOWED_HOSTS = ['www2.moldiscovery.com','localhost','127.0.0.1','ajax.googleapis.com'] SITE_ROOT = os.path.dirname(os.path.realpath(__file__)) -SERVER_EMAIL = 'admin@ml.moldiscovery.com' +SERVER_EMAIL = 'admin@www2.moldiscovery.com' ADMINS = ( ('SysAdmin', 'fabrizio@moldiscovery.com'), @@ -51,7 +51,8 @@ # Absolute filesystem path to the directory that will hold user-uploaded files. # Example: "/home/media/media.lawrence.com/media/" -MEDIA_ROOT = os.path.abspath(os.path.dirname(__file__)) + '/media/' +#MEDIA_ROOT = os.path.abspath(os.path.dirname(__file__)) + '/media/' +MEDIA_ROOT = '/var/media-storage/' # URL that handles the media served from MEDIA_ROOT. Make sure to use a # trailing slash. @@ -157,4 +158,4 @@ 'propagate': True, }, } -} \ No newline at end of file +} diff --git a/static/css/jquery.fileupload-ui.css b/static/css/jquery.fileupload-ui.css new file mode 100644 index 0000000..693862f --- /dev/null +++ b/static/css/jquery.fileupload-ui.css @@ -0,0 +1,114 @@ +@charset "UTF-8"; +/* + * jQuery File Upload UI Plugin CSS 8.8.1 + * https://github.com/blueimp/jQuery-File-Upload + * + * Copyright 2010, Sebastian Tschan + * https://blueimp.net + * + * Licensed under the MIT license: + * http://www.opensource.org/licenses/MIT + */ + +.fileinput-button { + position: relative; + overflow: hidden; +} +.fileinput-button input { + position: absolute; + top: 0; + right: 0; + margin: 0; + opacity: 0; + filter: alpha(opacity=0); + transform: translate(-300px, 0) scale(4); + font-size: 23px; + direction: ltr; + cursor: pointer; +} +.fileupload-buttonbar .btn, +.fileupload-buttonbar .toggle { + margin-bottom: 5px; +} +.progress-animated .progress-bar, +.progress-animated .bar { + background: url(../img/progressbar.gif) !important; + filter: none; +} + + +.ui-state-default, .ui-widget-content .ui-state-default, .ui-widget-header .ui-state-default { + background: none repeat scroll 0 0 #005491; + border: 1px solid #515091; + color: #EEEEEE; + font-weight: bold; + margin: 0px; +} + +.ui-widget-content { + border: 1px solid #555555; + height: 14px; + margin-bottom: 10px; + width: 80%; + background: #000000 url(../img/progressbar.gif) 50% 50% repeat; + color: #ffffff; +} + +.ui-widget-header { +border: 1px solid #798E9B; +/*background: #388532 url(images/ui-bg_highlight-soft_44_444444_1x100.png) 50% 50% repeat-x;*/ +background: #005491 url(../img/ui-bg_highlight-soft_44_444444_1x100.png) 50% 50% repeat-x; +color: #ffffff; +font-weight: bold; +} + +.ui-widget { + font-size: 0.92em; +} + +.ui-corner-all, .ui-corner-bottom, .ui-corner-right, .ui-corner-br { + border-bottom-right-radius: 6px; +} +.ui-corner-all, .ui-corner-bottom, .ui-corner-left, .ui-corner-bl { + border-bottom-left-radius: 6px; +} + +.ui-corner-all, .ui-corner-top, .ui-corner-right, .ui-corner-tr { + border-top-right-radius: 6px; +} +.ui-corner-all, .ui-corner-top, .ui-corner-left, .ui-corner-tl { + border-top-left-radius: 6px; +} + +/*.fileupload-loading { + float: right; + width: 32px; + height: 32px; + background: url(../img/loading.gif) center no-repeat; + background-size: contain; + display: none; +}*/ + +.fileupload-processing .fileupload-loading { + display: block; +} +.files audio, +.files video { + max-width: 300px; +} + +@media (max-width: 767px) { + .fileupload-buttonbar .toggle, + .files .toggle, + .files .btn span { + display: none; + } + .files .name { + width: 80px; + word-wrap: break-word; + } + .files audio, + .files video { + max-width: 80px; + } +} From 700759029520954a3f198b6fe47dab956990aa84 Mon Sep 17 00:00:00 2001 From: fburatta Date: Fri, 12 Aug 2016 08:25:18 +0200 Subject: [PATCH 46/57] fix file removal on the disk --- fileupload/models.py | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/fileupload/models.py b/fileupload/models.py index 9a09f77..95041c0 100644 --- a/fileupload/models.py +++ b/fileupload/models.py @@ -1,5 +1,10 @@ # encoding: utf-8 from django.db import models +# Receive the pre_delete signal and delete the file associated with the model instance. +from django.db.models.signals import post_delete +from django.dispatch.dispatcher import receiver + + def upload_dir_path(instance, filename): return 'uploaded_files/%s/%s' % (instance.username, filename) @@ -26,7 +31,13 @@ def save(self, *args, **kwargs): self.slug = self.file.name super(File, self).save(*args, **kwargs) - def delete(self, *args, **kwargs): - """delete -- Remove to leave file.""" - self.file.delete(False) - super(File, self).delete(*args, **kwargs) + # use post_delete signal instead + #def delete(self, *args, **kwargs): + # """delete -- Remove to leave file.""" + # self.file.delete(False) + # super(File, self).delete(*args, **kwargs) + +@receiver(post_delete, sender=File) +def File_delete(sender, instance, **kwargs): + # Pass false so FileField doesn't save the model. + instance.file.delete(False) From 11a96c4a4d5178ec52807132e86970e799fdab73 Mon Sep 17 00:00:00 2001 From: fab Date: Fri, 12 Aug 2016 07:25:10 +0000 Subject: [PATCH 47/57] added apache and selinux configurations --- deploy/apache/apache.conf | 52 +++++++++++++++++++++++++++++++++ deploy/selinux/djuploader2.0.te | 12 ++++++++ 2 files changed, 64 insertions(+) create mode 100644 deploy/apache/apache.conf create mode 100644 deploy/selinux/djuploader2.0.te diff --git a/deploy/apache/apache.conf b/deploy/apache/apache.conf new file mode 100644 index 0000000..0612f85 --- /dev/null +++ b/deploy/apache/apache.conf @@ -0,0 +1,52 @@ +# WSGISocketPrefix +WSGISocketPrefix /var/run/wsgi +WSGIPythonPath /path_to_app:/path_to_virtualenv/lib/python2.7/site-packages + +################### +# web uploads +# + +# config from http://wiki.apache.org/httpd/NameBasedSSLVHosts + SSLEngine on + SSLCipherSuite ALL:!ADH:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv2:+EXP + + SSLCertificateFile /etc/ssl/certs/cert.com.crt + SSLCertificateKeyFile /etc/ssl/certs/cert.com.key + SSLCertificateChainFile /etc/ssl/certs/StandardSSLCA.pem + SSLVerifyClient None + + ServerName "foo" + ServerAdmin "webmaster@foo" + + CustomLog "/var/log/httpd/upload-access.log" combined + ErrorLog "/var/log/httpd/upload-error.log" + + # Django file uploader + ################################################### + Alias /media/ /var/media-storage/ + AliasMatch ^/([^/]*\.css) /path_to_app/static/css/$1 + Alias /static/ /path_to_app/static/ + + + Require all granted + + + + Require all denied + + + WSGIScriptAlias /secureupload /path_to_app/core/wsgi.py + + + SSLRequireSSL + + + Require all granted + + + + +# END WEBUPLOADS +################# + +# /* vim: set expandtab tabstop=4 shiftwidth=4: */ diff --git a/deploy/selinux/djuploader2.0.te b/deploy/selinux/djuploader2.0.te new file mode 100644 index 0000000..9e96269 --- /dev/null +++ b/deploy/selinux/djuploader2.0.te @@ -0,0 +1,12 @@ + +module djuploader 1.0; + +require { + type httpd_t; + type var_t; + class file { getattr unlink }; +} + +#============= httpd_t ============== +allow httpd_t var_t:file unlink; +allow httpd_t var_t:file getattr; From bded78e8b48c433aa26c0c68e3b2e59affa544f2 Mon Sep 17 00:00:00 2001 From: fab Date: Mon, 22 Aug 2016 08:52:12 +0000 Subject: [PATCH 48/57] hostname changed and related fixes to jquery scripts and django config --- fileupload/admin.py | 4 ++-- fileupload/static/js/main.js | 2 +- fileupload/views.py | 6 +++--- settings.py | 2 +- static/css/jquery.fileupload-ui.css | 4 ++-- 5 files changed, 9 insertions(+), 9 deletions(-) diff --git a/fileupload/admin.py b/fileupload/admin.py index 3504d2e..c8d3c6b 100644 --- a/fileupload/admin.py +++ b/fileupload/admin.py @@ -24,8 +24,8 @@ def make_download(modeladmin, request, queryset): tarred = tarfile.open(fileobj=response, mode='w:gz') - if not validate_size(queryset,500000000): - messages.warning(request, "Download group is too big, unselect some files or select just 1, max size of multple download: 500 MB") + if not validate_size(queryset,1000000000): + messages.warning(request, "Download group is too big, unselect some files or select just 1, max size of multple download: 1.0 GB") else: diff --git a/fileupload/static/js/main.js b/fileupload/static/js/main.js index 47d960a..3a2add2 100644 --- a/fileupload/static/js/main.js +++ b/fileupload/static/js/main.js @@ -40,7 +40,7 @@ $(function () { // Uncomment the following to send cross-domain cookies: //xhrFields: {withCredentials: true}, //url: $('#fileupload').fileupload('option', 'url'), - url: 'https://ml.moldiscovery.com:8888/uploader/upload/view/', + url: 'https://upload.moldiscovery.com/secureupload/upload/view/', dataType: 'json', context: $('#fileupload')[0] }).always(function () { diff --git a/fileupload/views.py b/fileupload/views.py index cf799f6..0be5568 100644 --- a/fileupload/views.py +++ b/fileupload/views.py @@ -13,7 +13,7 @@ def send_email(response,user): - FROMADDR = "uploads@ml.moldiscovery.com" + FROMADDR = "uploads@www2.moldiscovery.com" LOGIN = FROMADDR #PASSWORD = "" TOADDRS = ["fabrizio@moldiscovery.com"] @@ -23,7 +23,7 @@ def send_email(response,user): for file in response['files']: msg_content += "File Uploaded: "+ file['name'] + '\r\n' msg_content += "File Size: "+ str(file['size']) + ' bytes\r\n' - msg_content += "Download: https://ml.moldiscovery.com:8888/uploader"+ file['url'] + '\r\n\r\n' + msg_content += "Download: https://www2.moldiscovery.com/secureupload/admin/" + '\r\n\r\n' msg = ("From: %s\r\nTo: %s\r\nSubject: %s\r\n\r\n" % (FROMADDR, ", ".join(TOADDRS), SUBJECT) ) @@ -31,7 +31,7 @@ def send_email(response,user): server = smtplib.SMTP('localhost', 25) #server.set_debuglevel(1) - server.ehlo("ml.moldiscovery.com") + server.ehlo("www2.moldiscovery.com") #server.starttls() #server.login(LOGIN, PASSWORD) server.sendmail(FROMADDR, TOADDRS, msg) diff --git a/settings.py b/settings.py index 7b0689f..7b0832d 100644 --- a/settings.py +++ b/settings.py @@ -3,7 +3,7 @@ DEBUG = False TEMPLATE_DEBUG = DEBUG -ALLOWED_HOSTS = ['www2.moldiscovery.com','localhost','127.0.0.1','ajax.googleapis.com'] +ALLOWED_HOSTS = ['upload.moldiscovery.com','www2.moldiscovery.com','localhost','127.0.0.1','ajax.googleapis.com'] SITE_ROOT = os.path.dirname(os.path.realpath(__file__)) diff --git a/static/css/jquery.fileupload-ui.css b/static/css/jquery.fileupload-ui.css index 693862f..6d96259 100644 --- a/static/css/jquery.fileupload-ui.css +++ b/static/css/jquery.fileupload-ui.css @@ -80,14 +80,14 @@ font-weight: bold; border-top-left-radius: 6px; } -/*.fileupload-loading { +.fileupload-loading { float: right; width: 32px; height: 32px; background: url(../img/loading.gif) center no-repeat; background-size: contain; display: none; -}*/ +} .fileupload-processing .fileupload-loading { display: block; From 14070e290c6bcc6e171a590207498183dcf7acbf Mon Sep 17 00:00:00 2001 From: fab Date: Fri, 24 Jan 2020 13:52:45 +0000 Subject: [PATCH 49/57] give some advise on max file upload size cause: systemd privateTMP for httpd --- fileupload/templates/fileupload/file_jquery_form.html | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/fileupload/templates/fileupload/file_jquery_form.html b/fileupload/templates/fileupload/file_jquery_form.html index b190ed6..1571158 100644 --- a/fileupload/templates/fileupload/file_jquery_form.html +++ b/fileupload/templates/fileupload/file_jquery_form.html @@ -50,7 +50,10 @@
- +

Molecular Discovery Secure File Upload.


( TIP: Compress your files when possible. )

Molecular Discovery Secure File Upload.

+

MAX cumulative files upload size: 4 GB

+

TIP: compress or chunck big files before uploading

+
From 6c601ac4776f1d458a3c78cdacf62493ad2653c3 Mon Sep 17 00:00:00 2001 From: fab Date: Fri, 24 Jan 2020 14:16:56 +0000 Subject: [PATCH 50/57] minor --- fileupload/templates/fileupload/file_jquery_form.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fileupload/templates/fileupload/file_jquery_form.html b/fileupload/templates/fileupload/file_jquery_form.html index 1571158..e1d5c68 100644 --- a/fileupload/templates/fileupload/file_jquery_form.html +++ b/fileupload/templates/fileupload/file_jquery_form.html @@ -51,7 +51,7 @@ From a6c9defad8032d947e4bbe9995154a7d0579e48c Mon Sep 17 00:00:00 2001 From: fburatta Date: Thu, 14 Mar 2024 08:42:34 +0100 Subject: [PATCH 51/57] added Date field migration --- fileupload/admin.py | 8 +++-- fileupload/migrations/0001_initial.py | 36 +++++++++++++++++++ .../0002_auto__add_field_file_date.py | 33 +++++++++++++++++ fileupload/migrations/__init__.py | 0 fileupload/models.py | 14 +++----- requirements.txt | 5 +-- settings_dev.py | 1 + 7 files changed, 83 insertions(+), 14 deletions(-) create mode 100644 fileupload/migrations/0001_initial.py create mode 100644 fileupload/migrations/0002_auto__add_field_file_date.py create mode 100644 fileupload/migrations/__init__.py diff --git a/fileupload/admin.py b/fileupload/admin.py index c8d3c6b..b9e6c7f 100644 --- a/fileupload/admin.py +++ b/fileupload/admin.py @@ -6,6 +6,7 @@ from django.contrib import messages from django.conf import settings import os.path, time +import datetime as dt def validate_size(files, maxsize): total_size = 0 @@ -74,13 +75,14 @@ def file_size(obj): file_size.short_description = 'Size' def last_modified(obj): - date_text = "%s" % time.ctime(os.path.getmtime(settings.MEDIA_ROOT+obj.file.name)) + date_text = "%s" % dt.datetime.fromtimestamp(os.path.getmtime(settings.MEDIA_ROOT+obj.file.name)) return date_text class FileAdmin(admin.ModelAdmin): - list_display = ('slug','username', file_size, last_modified) + list_display = ('slug','username', 'date', file_size, last_modified) + list_filter = ('username',) search_fields = ['slug', 'username'] - ordering = ('username','slug') + ordering = ('username','slug', 'date') actions = [make_download,make_archive] diff --git a/fileupload/migrations/0001_initial.py b/fileupload/migrations/0001_initial.py new file mode 100644 index 0000000..3d87f52 --- /dev/null +++ b/fileupload/migrations/0001_initial.py @@ -0,0 +1,36 @@ +# -*- coding: utf-8 -*- +from south.utils import datetime_utils as datetime +from south.db import db +from south.v2 import SchemaMigration +from django.db import models + + +class Migration(SchemaMigration): + + def forwards(self, orm): + # Adding model 'File' + db.create_table(u'fileupload_file', ( + (u'id', self.gf('django.db.models.fields.AutoField')(primary_key=True)), + ('file', self.gf('django.db.models.fields.files.FileField')(max_length=100)), + ('slug', self.gf('django.db.models.fields.SlugField')(max_length=50, blank=True)), + ('username', self.gf('django.db.models.fields.CharField')(max_length=50)), + )) + db.send_create_signal(u'fileupload', ['File']) + + + def backwards(self, orm): + # Deleting model 'File' + db.delete_table(u'fileupload_file') + + + models = { + u'fileupload.file': { + 'Meta': {'object_name': 'File'}, + 'file': ('django.db.models.fields.files.FileField', [], {'max_length': '100'}), + u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'slug': ('django.db.models.fields.SlugField', [], {'max_length': '50', 'blank': 'True'}), + 'username': ('django.db.models.fields.CharField', [], {'max_length': '50'}) + } + } + + complete_apps = ['fileupload'] \ No newline at end of file diff --git a/fileupload/migrations/0002_auto__add_field_file_date.py b/fileupload/migrations/0002_auto__add_field_file_date.py new file mode 100644 index 0000000..45648fa --- /dev/null +++ b/fileupload/migrations/0002_auto__add_field_file_date.py @@ -0,0 +1,33 @@ +# -*- coding: utf-8 -*- +from south.utils import datetime_utils as datetime +from south.db import db +from south.v2 import SchemaMigration +from django.db import models + + +class Migration(SchemaMigration): + + def forwards(self, orm): + # Adding field 'File.date' + db.add_column(u'fileupload_file', 'date', + self.gf('django.db.models.fields.DateTimeField')(default=datetime.datetime.now, blank=True), + keep_default=False) + + + def backwards(self, orm): + # Deleting field 'File.date' + db.delete_column(u'fileupload_file', 'date') + + + models = { + u'fileupload.file': { + 'Meta': {'object_name': 'File'}, + 'date': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now', 'blank': 'True'}), + 'file': ('django.db.models.fields.files.FileField', [], {'max_length': '100'}), + u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'slug': ('django.db.models.fields.SlugField', [], {'max_length': '50', 'blank': 'True'}), + 'username': ('django.db.models.fields.CharField', [], {'max_length': '50'}) + } + } + + complete_apps = ['fileupload'] \ No newline at end of file diff --git a/fileupload/migrations/__init__.py b/fileupload/migrations/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/fileupload/models.py b/fileupload/models.py index 95041c0..8f40fa6 100644 --- a/fileupload/models.py +++ b/fileupload/models.py @@ -1,4 +1,5 @@ # encoding: utf-8 +from datetime import datetime from django.db import models # Receive the pre_delete signal and delete the file associated with the model instance. from django.db.models.signals import post_delete @@ -10,13 +11,8 @@ def upload_dir_path(instance, filename): return 'uploaded_files/%s/%s' % (instance.username, filename) class File(models.Model): - """This is a small demo using just two fields. The slug field is really not - necessary, but makes the code simpler. ImageField depends on PIL or - pillow (where Pillow is easily installable in a virtualenv. If you have - problems installing pillow, use a more generic FileField instead. - - """ file = models.FileField(upload_to=upload_dir_path) + date = models.DateTimeField(default=datetime.now, blank=True) slug = models.SlugField(max_length=50, blank=True, verbose_name="file name") username = models.CharField(max_length=50) @@ -27,9 +23,9 @@ def __unicode__(self): def get_absolute_url(self): return ('upload-new', ) - def save(self, *args, **kwargs): - self.slug = self.file.name - super(File, self).save(*args, **kwargs) + # def save(self, *args, **kwargs): + # self.slug = self.file.name + # super(File, self).save(*args, **kwargs) # use post_delete signal instead #def delete(self, *args, **kwargs): diff --git a/requirements.txt b/requirements.txt index 23cb63a..8790390 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,2 +1,3 @@ -django<1.6 -pillow +django==1.5.12 +pillow==6.2.2 +South==1.0.2 diff --git a/settings_dev.py b/settings_dev.py index 23fdb0c..4806e13 100644 --- a/settings_dev.py +++ b/settings_dev.py @@ -125,6 +125,7 @@ 'fileupload', # Uncomment the next line to enable the admin: 'django.contrib.admin', + 'south' # Uncomment the next line to enable admin documentation: # 'django.contrib.admindocs', ) From c3d16a83dd2337152b2a436b4b7d13f2982cb407 Mon Sep 17 00:00:00 2001 From: fburatta Date: Thu, 14 Mar 2024 08:48:09 +0100 Subject: [PATCH 52/57] update db objects date with files last mod date --- utils/update_datefield.py | 41 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 utils/update_datefield.py diff --git a/utils/update_datefield.py b/utils/update_datefield.py new file mode 100644 index 0000000..f8ca3e4 --- /dev/null +++ b/utils/update_datefield.py @@ -0,0 +1,41 @@ +import datetime as dt +import os +from fileupload.models import File +from django.conf import settings + + +def sync_slug(allobj): + """ + fill slug field from file name when missing + """ + for obj in allobj: + obj.slug = os.path.basename(obj.file.name) + obj.save() + print("fix missing slug: %s") % obj.slug + +db_files = File.objects.all() +uploads_path = os.path.join(settings.MEDIA_ROOT,'uploaded_files') +users = set() + +sync_slug(db_files) + +for f in db_files: + users.add(f.username) + +for user_dir in users: + user_files = os.listdir(os.path.join(uploads_path, user_dir)) + print(user_dir + " " + str(len(user_files))) + for fname in user_files: + # only if there are duplicated + print("processa "+ " dir: "+user_dir +" name: " + fname) + qset = File.objects.filter(username=user_dir, slug=fname) + + if not qset: + print("ERROR: file %s/%s not found") % (user_dir, fname) + + if len(qset) > 1: + print("%s/%s is duplicated") % (user_dir, fname) + + obj = qset[0] + obj.date = dt.datetime.fromtimestamp(os.path.getmtime(os.path.join(uploads_path, user_dir,obj.slug))) + obj.save() \ No newline at end of file From bed1a6a36ea7d690288ee00a0bd1e951ce7e410c Mon Sep 17 00:00:00 2001 From: fburatta Date: Thu, 14 Mar 2024 11:25:05 +0100 Subject: [PATCH 53/57] avoid admin crash if files not found --- fileupload/admin.py | 18 +++++++++++++----- fileupload/models.py | 6 +++--- 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/fileupload/admin.py b/fileupload/admin.py index b9e6c7f..d1e01e7 100644 --- a/fileupload/admin.py +++ b/fileupload/admin.py @@ -69,14 +69,22 @@ def make_archive(modeladmin, request, queryset): def file_size(obj): - if obj.file.size < 1000000: - return ("%s bytes" % (obj.file.size)) - return ("%s MBs" % (obj.file.size/1000000)) + try: + if obj.file.size < 1000000: + return ("%s bytes" % (obj.file.size)) + return ("%s MBs" % (obj.file.size/1000000)) + except OSError: + return ("File Not found") + file_size.short_description = 'Size' def last_modified(obj): - date_text = "%s" % dt.datetime.fromtimestamp(os.path.getmtime(settings.MEDIA_ROOT+obj.file.name)) - return date_text + date_text = "File Not Found" + filepath = settings.MEDIA_ROOT+obj.file.name + if os.path.exists(filepath): + date_text = "%s" % dt.datetime.fromtimestamp(os.path.getmtime(filepath)) + + return date_text class FileAdmin(admin.ModelAdmin): list_display = ('slug','username', 'date', file_size, last_modified) diff --git a/fileupload/models.py b/fileupload/models.py index 8f40fa6..3fcee50 100644 --- a/fileupload/models.py +++ b/fileupload/models.py @@ -23,9 +23,9 @@ def __unicode__(self): def get_absolute_url(self): return ('upload-new', ) - # def save(self, *args, **kwargs): - # self.slug = self.file.name - # super(File, self).save(*args, **kwargs) + def save(self, *args, **kwargs): + self.slug = self.file.name + super(File, self).save(*args, **kwargs) # use post_delete signal instead #def delete(self, *args, **kwargs): From e3322ae467b453644857ecc1975ec8461a4e8299 Mon Sep 17 00:00:00 2001 From: fburatta Date: Thu, 14 Mar 2024 12:21:26 +0100 Subject: [PATCH 54/57] details --- fileupload/admin.py | 7 ++++--- utils/update_datefield.py | 3 --- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/fileupload/admin.py b/fileupload/admin.py index d1e01e7..c924e8d 100644 --- a/fileupload/admin.py +++ b/fileupload/admin.py @@ -78,18 +78,19 @@ def file_size(obj): file_size.short_description = 'Size' +# deprecated def last_modified(obj): date_text = "File Not Found" filepath = settings.MEDIA_ROOT+obj.file.name - if os.path.exists(filepath): + if os.path.exists(filepath): date_text = "%s" % dt.datetime.fromtimestamp(os.path.getmtime(filepath)) return date_text class FileAdmin(admin.ModelAdmin): - list_display = ('slug','username', 'date', file_size, last_modified) + list_display = ('slug','username', 'date', file_size) list_filter = ('username',) - search_fields = ['slug', 'username'] + search_fields = ['slug', 'username', 'date'] ordering = ('username','slug', 'date') actions = [make_download,make_archive] diff --git a/utils/update_datefield.py b/utils/update_datefield.py index f8ca3e4..809a589 100644 --- a/utils/update_datefield.py +++ b/utils/update_datefield.py @@ -29,13 +29,10 @@ def sync_slug(allobj): # only if there are duplicated print("processa "+ " dir: "+user_dir +" name: " + fname) qset = File.objects.filter(username=user_dir, slug=fname) - if not qset: print("ERROR: file %s/%s not found") % (user_dir, fname) - if len(qset) > 1: print("%s/%s is duplicated") % (user_dir, fname) - obj = qset[0] obj.date = dt.datetime.fromtimestamp(os.path.getmtime(os.path.join(uploads_path, user_dir,obj.slug))) obj.save() \ No newline at end of file From e194c7ff0fe57aad17546ec2a87dd7f6227a0dac Mon Sep 17 00:00:00 2001 From: fburatta Date: Thu, 14 Mar 2024 15:52:14 +0100 Subject: [PATCH 55/57] readme update --- README.md | 39 +++++++++++++++++++++------------------ utils/update_datefield.py | 3 +++ 2 files changed, 24 insertions(+), 18 deletions(-) diff --git a/README.md b/README.md index 8f185a9..863f189 100644 --- a/README.md +++ b/README.md @@ -1,23 +1,8 @@ -[jQuery-File-Upload](http://aquantum-demo.appspot.com/file-upload) is developed by Sebastian Tschan, with the source available on [github](https://github.com/blueimp/jQuery-File-Upload). Example code is [ported to Django](https://github.com/sigurdga/django-jquery-file-upload) by Sigurd Gartmann ([sigurdga on github](https://github.com/sigurdga/)). +Disclaimer +========== -Introduction -============ - -This is a small example on how to setup Sebastian Tschan's jQuery File Upload in Django. He has a working demo on his [webpage](http://aquantum-demo.appspot.com/file-upload) and a [github repository](https://github.com/blueimp/jQuery-File-Upload) with an example on how to do it in PHP. - -Here, you'll find a minimal Django project with a minimal app. You can run the example standalone by cloning the repository, running the migrations and starting the server. - -I want to give a thank to [Sebastian Tschan](https://github.com/blueimp), the original author, [Etay Cohen-Solal](https://github.com/et-cs), for the latest major update, and [Jørgen Bergquist](https://github.com/bergquis) for helping me over the first hurdles. - -Features -======== +This project is a fork -* Drag and drop files -* Select multiple files -* Cancel upload -* Delete uploaded file (from database only) -* No flash (or other browser plugins) needed -* … more at the [upstream's features page](http://aquantum-demo.appspot.com/file-upload#features) Requirements ============ @@ -37,6 +22,24 @@ Installation * python manage.py runserver * go to localhost:8000/upload/new/ and upload some files +Developing with docker +====================== + $ docker run -ti --name uploaderdevel -p 8000:8000 -v /workdir/django_uploader:/devel python:2.7.18 bash + $ pip install -r requirements.txt + $ python manage.py runserver 0.0.0.0:8000 + +Database migrations +=================== + +From existing DB + $ python manage.py schemamigration fileupload --initial + $ python manage.py migrate --fake + + +Generate migration and apply + $ python manage.py schemamigration fileupload --auto + $ python manage.py migrate fileupload + License ======= MIT, as the original project. See LICENSE.txt. diff --git a/utils/update_datefield.py b/utils/update_datefield.py index 809a589..b894412 100644 --- a/utils/update_datefield.py +++ b/utils/update_datefield.py @@ -1,3 +1,6 @@ +# This script can be invoked from python manage.py shell. It's aim is to update the Date Field of the fileupload model +# with the dates of existing files in the media storage and associated to the model object + import datetime as dt import os from fileupload.models import File From eef1d0087cda21ae97ecc40801e7ccfdab5c8643 Mon Sep 17 00:00:00 2001 From: fburatta Date: Mon, 18 Mar 2024 11:47:35 +0100 Subject: [PATCH 56/57] fix date null on creation DB error --- README.md | 1 + fileupload/models.py | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 863f189..a5596da 100644 --- a/README.md +++ b/README.md @@ -26,6 +26,7 @@ Developing with docker ====================== $ docker run -ti --name uploaderdevel -p 8000:8000 -v /workdir/django_uploader:/devel python:2.7.18 bash $ pip install -r requirements.txt + $ export DJANGO_SETTINGS_MODULE=settings_dev $ python manage.py runserver 0.0.0.0:8000 Database migrations diff --git a/fileupload/models.py b/fileupload/models.py index 3fcee50..aff009f 100644 --- a/fileupload/models.py +++ b/fileupload/models.py @@ -12,7 +12,7 @@ def upload_dir_path(instance, filename): class File(models.Model): file = models.FileField(upload_to=upload_dir_path) - date = models.DateTimeField(default=datetime.now, blank=True) + date = models.DateTimeField(auto_now_add=True, blank=True) slug = models.SlugField(max_length=50, blank=True, verbose_name="file name") username = models.CharField(max_length=50) From 2562e32ce1301cb4c618ace3c364a167fd1c24d1 Mon Sep 17 00:00:00 2001 From: fburatta Date: Mon, 18 Mar 2024 11:50:26 +0100 Subject: [PATCH 57/57] forgot migration file --- .../0003_auto__chg_field_file_date.py | 31 +++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 fileupload/migrations/0003_auto__chg_field_file_date.py diff --git a/fileupload/migrations/0003_auto__chg_field_file_date.py b/fileupload/migrations/0003_auto__chg_field_file_date.py new file mode 100644 index 0000000..24d9c92 --- /dev/null +++ b/fileupload/migrations/0003_auto__chg_field_file_date.py @@ -0,0 +1,31 @@ +# -*- coding: utf-8 -*- +from south.utils import datetime_utils as datetime +from south.db import db +from south.v2 import SchemaMigration +from django.db import models + + +class Migration(SchemaMigration): + + def forwards(self, orm): + + # Changing field 'File.date' + db.alter_column(u'fileupload_file', 'date', self.gf('django.db.models.fields.DateTimeField')(auto_now_add=True)) + + def backwards(self, orm): + + # Changing field 'File.date' + db.alter_column(u'fileupload_file', 'date', self.gf('django.db.models.fields.DateTimeField')()) + + models = { + u'fileupload.file': { + 'Meta': {'object_name': 'File'}, + 'date': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}), + 'file': ('django.db.models.fields.files.FileField', [], {'max_length': '100'}), + u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'slug': ('django.db.models.fields.SlugField', [], {'max_length': '50', 'blank': 'True'}), + 'username': ('django.db.models.fields.CharField', [], {'max_length': '50'}) + } + } + + complete_apps = ['fileupload'] \ No newline at end of file

Molecular Discovery Secure File Upload.

-

MAX cumulative files upload size: 4 GB

+

MAX aggregated files upload size: 4 GB


TIP: compress or chunck big files before uploading