From 124e2838fbd48f1eab3e025f3ea13803489aae72 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=81lex=20Hermida?= Date: Fri, 7 Sep 2018 12:47:43 +0200 Subject: [PATCH] Save attachment values diff with attached file --- taiga/projects/history/freeze_impl.py | 1 + taiga/timeline/serializers.py | 11 ++++++----- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/taiga/projects/history/freeze_impl.py b/taiga/projects/history/freeze_impl.py index 48aae73d..d5292eaa 100644 --- a/taiga/projects/history/freeze_impl.py +++ b/taiga/projects/history/freeze_impl.py @@ -203,6 +203,7 @@ def extract_attachments(obj) -> list: yield {"id": attach.id, "filename": os.path.basename(attach.attached_file.name), "url": attach.attached_file.url, + "attached_file": str(attach.attached_file), "thumb_url": thumb_url, "is_deprecated": attach.is_deprecated, "description": attach.description, diff --git a/taiga/timeline/serializers.py b/taiga/timeline/serializers.py index 1c9413e2..5e39c0aa 100644 --- a/taiga/timeline/serializers.py +++ b/taiga/timeline/serializers.py @@ -74,10 +74,11 @@ class TimelineSerializer(serializers.LightSerializer): return obj.data def parse_url(self, item): - file_path = urlparse(item['url']).path - index = file_path.find('/attachments') - attached_file = file_path[index+1:] + if 'attached_file' in item: + attached_file = item['attached_file'] + else: + file_path = urlparse(item['url']).path + index = file_path.find('/attachments') + attached_file = file_path[index+1:] item['url'] = default_storage.url(attached_file) - - return item['url']