From 126dcfd609ee92b823a029d4d3e8d52ae7cef943 Mon Sep 17 00:00:00 2001 From: Roberto Rosario Date: Thu, 10 Oct 2019 17:15:45 -0400 Subject: [PATCH 1/5] Split source multiform template Signed-off-by: Roberto Rosario --- .../sources/templates/sources/dropzone.html | 115 +++++++++++++++++ .../sources/upload_multiform_subtemplate.html | 118 +----------------- 2 files changed, 116 insertions(+), 117 deletions(-) create mode 100644 mayan/apps/sources/templates/sources/dropzone.html diff --git a/mayan/apps/sources/templates/sources/dropzone.html b/mayan/apps/sources/templates/sources/dropzone.html new file mode 100644 index 0000000000..9f2118eb62 --- /dev/null +++ b/mayan/apps/sources/templates/sources/dropzone.html @@ -0,0 +1,115 @@ +{% load i18n %} +{% load static %} + + + + + + + + diff --git a/mayan/apps/sources/templates/sources/upload_multiform_subtemplate.html b/mayan/apps/sources/templates/sources/upload_multiform_subtemplate.html index 573aeee391..100f5ae9c8 100644 --- a/mayan/apps/sources/templates/sources/upload_multiform_subtemplate.html +++ b/mayan/apps/sources/templates/sources/upload_multiform_subtemplate.html @@ -1,118 +1,2 @@ -{% load i18n %} -{% load static %} - - - - - {% include 'appearance/generic_multiform_subtemplate.html' %} - - - - - +{% include 'sources/dropzone.html' %} From 4afe81f30620e9adcd603423b40f457432540dd9 Mon Sep 17 00:00:00 2001 From: Roberto Rosario Date: Thu, 10 Oct 2019 17:16:16 -0400 Subject: [PATCH 2/5] Update document version upload to use dropzone Signed-off-by: Roberto Rosario --- mayan/apps/sources/views.py | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/mayan/apps/sources/views.py b/mayan/apps/sources/views.py index 782a4779c8..d0d98cd3c9 100644 --- a/mayan/apps/sources/views.py +++ b/mayan/apps/sources/views.py @@ -453,9 +453,15 @@ class DocumentVersionUploadInteractiveView(UploadBaseView): ) def get_form_classes(self): + source_form_class = get_upload_form_class(self.source.source_type) + + # Override source form class to enable the HTML5 file uploader + if source_form_class == WebFormUploadForm: + source_form_class = WebFormUploadFormHTML5 + return { 'document_form': NewVersionForm, - 'source_form': get_upload_form_class(self.source.source_type) + 'source_form': source_form_class } def get_context_data(self, **kwargs): @@ -468,6 +474,14 @@ class DocumentVersionUploadInteractiveView(UploadBaseView): 'from source: %(source)s' ) % {'document': self.document, 'source': self.source.label} context['submit_label'] = _('Submit') + context['form_css_classes'] = 'dropzone' + context['form_disable_submit'] = True + context['form_action'] = '{}?{}'.format( + reverse( + viewname=self.request.resolver_match.view_name, + kwargs=self.request.resolver_match.kwargs + ), self.request.META['QUERY_STRING'] + ) return context From d865c60091a7fcd3d13287adc0a9606a1ccf2ee4 Mon Sep 17 00:00:00 2001 From: Roberto Rosario Date: Thu, 10 Oct 2019 17:18:12 -0400 Subject: [PATCH 3/5] Update changelog Signed-off-by: Roberto Rosario --- HISTORY.rst | 2 ++ 1 file changed, 2 insertions(+) diff --git a/HISTORY.rst b/HISTORY.rst index aea00e8a61..a61fdd6a1e 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -78,6 +78,8 @@ Support Docker networks and make it the default. Delete the containers to allow the script to be idempotent. Deploy a Redis container. +- Improve document version upload form. +- Use dropzone for document version upload form. 3.2.8 (2019-10-01) ================== From 5ea286d4bd07a4e65cee09d8dcaa4ccd902002c7 Mon Sep 17 00:00:00 2001 From: Roberto Rosario Date: Fri, 11 Oct 2019 09:07:48 -0400 Subject: [PATCH 4/5] Show page append link if new versions are allowed Signed-off-by: Roberto Rosario --- mayan/apps/sources/links.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mayan/apps/sources/links.py b/mayan/apps/sources/links.py index bd838ce13b..78fb22e753 100644 --- a/mayan/apps/sources/links.py +++ b/mayan/apps/sources/links.py @@ -114,7 +114,7 @@ link_staging_file_delete = Link( tags='dangerous', text=_('Delete'), view='sources:staging_file_delete', ) link_document_pages_append = Link( - args='resolved_object.pk', + args='resolved_object.pk', condition=document_new_version_not_blocked, icon_class_path='mayan.apps.sources.icons.icon_document_pages_append', permissions=(permission_document_new_version,), text=_('Append pages'), From 01e79b1089a35b15c8b00bf7202c4158c17e047e Mon Sep 17 00:00:00 2001 From: Roberto Rosario Date: Fri, 11 Oct 2019 09:08:51 -0400 Subject: [PATCH 5/5] Add OCR migration dependency Signed-off-by: Roberto Rosario --- mayan/apps/ocr/migrations/0001_initial.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/mayan/apps/ocr/migrations/0001_initial.py b/mayan/apps/ocr/migrations/0001_initial.py index 3270eeaf01..8f94bd59c6 100644 --- a/mayan/apps/ocr/migrations/0001_initial.py +++ b/mayan/apps/ocr/migrations/0001_initial.py @@ -9,6 +9,10 @@ class Migration(migrations.Migration): ('documents', '__first__'), ] + run_before = [ + ('documents', '0052_rename_document_page'), + ] + operations = [ migrations.CreateModel( name='DocumentVersionOCRError',