From c3e0ff84eca173b6f0b9eeda84da1fd921c6050d Mon Sep 17 00:00:00 2001 From: sandeepsajan0 <sandeepsajan0@gmail.com> Date: Wed, 9 Jun 2021 19:07:31 +0530 Subject: [PATCH] fix: Add created time before filename in Submission details --- hypha/apply/funds/models/mixins.py | 3 --- hypha/apply/stream_forms/files.py | 4 ++++ .../templates/stream_forms/includes/file_field.html | 1 + 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/hypha/apply/funds/models/mixins.py b/hypha/apply/funds/models/mixins.py index 246704a75..31612c8ef 100644 --- a/hypha/apply/funds/models/mixins.py +++ b/hypha/apply/funds/models/mixins.py @@ -1,5 +1,3 @@ -from datetime import datetime - from django.core.files import File from django.utils.safestring import mark_safe from django_file_form.models import PlaceholderUploadedFile @@ -58,7 +56,6 @@ class AccessFormData: if isinstance(file, cls.stream_file_class): return file if isinstance(file, File): - file.name = datetime.now().strftime("%y%m%d") + "-" + file.name return cls.stream_file_class(instance, field, file, name=file.name, storage=cls.storage_class()) if isinstance(file, PlaceholderUploadedFile): diff --git a/hypha/apply/stream_forms/files.py b/hypha/apply/stream_forms/files.py index 98786d03b..c098b4d10 100644 --- a/hypha/apply/stream_forms/files.py +++ b/hypha/apply/stream_forms/files.py @@ -79,6 +79,10 @@ class StreamFieldFile(File): return self.file.size return self.storage.size(self.name) + @property + def modification_time(self): + return self.storage.get_modified_time(self.name).date() + def serialize(self): return { 'url': self.url, diff --git a/hypha/apply/stream_forms/templates/stream_forms/includes/file_field.html b/hypha/apply/stream_forms/templates/stream_forms/includes/file_field.html index be1213532..1ff3d1109 100644 --- a/hypha/apply/stream_forms/templates/stream_forms/includes/file_field.html +++ b/hypha/apply/stream_forms/templates/stream_forms/includes/file_field.html @@ -1,6 +1,7 @@ <a class="link link--download" href="{{ file.url }}" target="_blank" rel="noopener noreferrer"> <div> <svg><use xlink:href="#file"></use></svg> + <span>{{ file.modification_time }}</span> <span>{{ file.filename }}</span> </div> <svg><use xlink:href="#download"></use></svg> -- GitLab