Skip to content
Snippets Groups Projects
Commit 7e497db6 authored by Todd Dembrey's avatar Todd Dembrey Committed by Fredrik Jonsson
Browse files

Tidy up the backwards compatibility change for #507

parent 52c29caf
No related branches found
No related tags found
No related merge requests found
...@@ -38,21 +38,24 @@ class AccessFormData: ...@@ -38,21 +38,24 @@ class AccessFormData:
@classmethod @classmethod
def stream_file(cls, file): def stream_file(cls, file):
if 'path' in file:
file['filename'] = file['name']
file['name'] = file['path']
if isinstance(file, StreamFieldFile): if isinstance(file, StreamFieldFile):
return file return file
if isinstance(file, File): if isinstance(file, File):
return StreamFieldFile(file, name=file.name, storage=submission_storage) return StreamFieldFile(file, name=file.name, storage=submission_storage)
# This fixes a backwards compatibility issue with #507
# Once every application has been re-saved it should be possible to remove it
if 'path' in file:
file['filename'] = file['name']
file['name'] = file['path']
return StreamFieldFile(None, name=file['name'], filename=file.get('filename'), storage=submission_storage) return StreamFieldFile(None, name=file['name'], filename=file.get('filename'), storage=submission_storage)
@classmethod @classmethod
def process_file(cls, file): def process_file(cls, file):
try: if isinstance(file, list):
return cls.stream_file(file)
except TypeError:
return [cls.stream_file(f) for f in file] return [cls.stream_file(f) for f in file]
else:
return cls.stream_file(file)
@classmethod @classmethod
def from_db(cls, db, field_names, values): def from_db(cls, db, field_names, values):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment