Fix uploading of staging files

This commit is contained in:
Roberto Rosario
2014-07-08 15:55:05 -04:00
parent b0783e5816
commit 5d46405800
2 changed files with 4 additions and 5 deletions

View File

@@ -28,7 +28,7 @@ class StagingDocumentForm(DocumentForm):
try:
self.fields['staging_file_id'].choices = [
(hash(staging_file), unicode(staging_file)) for staging_file in self.source.get_files()
(staging_file.encoded_filename, unicode(staging_file)) for staging_file in self.source.get_files()
]
except Exception as exception:
logger.error('exception: %s' % exception)

View File

@@ -230,7 +230,7 @@ def upload_interactive(request, source_type=None, source_id=None, document_pk=No
)
if form.is_valid():
try:
staging_file = StagingFile.get(form.cleaned_data['staging_file_id'])
staging_file = staging_folder.get_file(encoded_filename=form.cleaned_data['staging_file_id'])
if document:
expand = False
else:
@@ -245,7 +245,7 @@ def upload_interactive(request, source_type=None, source_id=None, document_pk=No
new_filename = get_form_filename(form)
result = staging_folder.upload_file(
staging_file.upload(),
staging_file.as_file(),
new_filename, use_file_name=form.cleaned_data.get('use_file_name', False),
document_type=document_type,
expand=expand,
@@ -267,8 +267,7 @@ def upload_interactive(request, source_type=None, source_id=None, document_pk=No
messages.warning(request, _(u'Staging file: %s, was not compressed, uploaded as a single file.') % staging_file.filename)
if staging_folder.delete_after_upload:
transformations, errors = staging_folder.get_transformation_list()
staging_file.delete(preview_size=staging_folder.get_preview_size(), transformations=transformations)
staging_file.delete()
messages.success(request, _(u'Staging file: %s, deleted successfully.') % staging_file.filename)
if document:
return HttpResponseRedirect(reverse('document_view_simple', args=[document.pk]))