diff --git a/apps/documents/forms.py b/apps/documents/forms.py index 62bd3fa00d..db6a6d8001 100644 --- a/apps/documents/forms.py +++ b/apps/documents/forms.py @@ -15,7 +15,7 @@ from .models import (Document, DocumentType, DocumentPage, DocumentPageTransformation, DocumentTypeFilename, DocumentVersion) from .widgets import document_html_widget -from .literals import (RELEASE_LEVEL_FINAL, RELEASE_LEVEL_CHOICES) +from .literals import (RELEASE_LEVEL_FINAL, RELEASE_LEVEL_CHOICES, DEFAULT_ZIP_FILENAME) # Document page forms @@ -316,7 +316,8 @@ class DocumentTypeFilenameForm_create(forms.ModelForm): class DocumentDownloadForm(forms.Form): compressed = forms.BooleanField(label=_(u'Compress'), required=False, help_text=_(u'Download the document in the original format or in a compressed manner. This option is selectable only when downloading one document, for multiple documents, the bundle will always be downloads as a compressed file.')) - + zip_filename = forms.CharField(initial=DEFAULT_ZIP_FILENAME, label=_(u'Compressed filename'), required=False, help_text=_(u'The filename of the compressed file that will contain the documents to be downloaded, if the previous option is selected.')) + def __init__(self, *args, **kwargs): self.document_versions = kwargs.pop('document_versions', None) super(DocumentDownloadForm, self).__init__(*args, **kwargs) diff --git a/apps/documents/literals.py b/apps/documents/literals.py index 0940d31109..9af7f52e5c 100644 --- a/apps/documents/literals.py +++ b/apps/documents/literals.py @@ -22,3 +22,5 @@ RELEASE_LEVEL_CHOICES = ( VERSION_UPDATE_MAJOR = u'major' VERSION_UPDATE_MINOR = u'minor' VERSION_UPDATE_MICRO = u'micro' + +DEFAULT_ZIP_FILENAME = u'document_bundle.zip' diff --git a/apps/documents/views.py b/apps/documents/views.py index 80d4112f3d..3b19744f4e 100644 --- a/apps/documents/views.py +++ b/apps/documents/views.py @@ -370,8 +370,8 @@ def document_download(request, document_id=None, document_id_list=None, document return serve_file( request, - compressed_file.as_file('document_bundle.zip'), - save_as=u'"document_bundle.zip"', + compressed_file.as_file(form.cleaned_data['zip_filename']), + save_as=u'"%s"' % form.cleaned_data['zip_filename'], content_type='application/zip' ) # TODO: DO a redirection afterwards @@ -409,6 +409,7 @@ def document_download(request, document_id=None, document_id_list=None, document 'submit_label': _(u'Download'), 'previous': previous, 'cancel_label': _(u'Return'), + 'disable_auto_focus': True, } if len(document_versions) == 1: