From 7e497db65e0b1dd30d069ac97eae46be1ce41751 Mon Sep 17 00:00:00 2001 From: Todd Dembrey <todd.dembrey@torchbox.com> Date: Sat, 15 Sep 2018 15:41:35 +0100 Subject: [PATCH] Tidy up the backwards compatibility change for #507 --- opentech/apply/funds/models/mixins.py | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/opentech/apply/funds/models/mixins.py b/opentech/apply/funds/models/mixins.py index 91779f3d1..54c23e415 100644 --- a/opentech/apply/funds/models/mixins.py +++ b/opentech/apply/funds/models/mixins.py @@ -38,21 +38,24 @@ class AccessFormData: @classmethod def stream_file(cls, file): - if 'path' in file: - file['filename'] = file['name'] - file['name'] = file['path'] if isinstance(file, StreamFieldFile): return file if isinstance(file, File): 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) @classmethod def process_file(cls, file): - try: - return cls.stream_file(file) - except TypeError: + if isinstance(file, list): return [cls.stream_file(f) for f in file] + else: + return cls.stream_file(file) @classmethod def from_db(cls, db, field_names, values): -- GitLab