From e4ad4a5127a684137f822998dbed12dbf6f704ec Mon Sep 17 00:00:00 2001 From: Ernesto Revilla Date: Sun, 8 Mar 2020 19:55:43 +0100 Subject: [PATCH 1/2] Avoid double save. --- file_resubmit/widgets.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/file_resubmit/widgets.py b/file_resubmit/widgets.py index 7980c74..5ceffed 100644 --- a/file_resubmit/widgets.py +++ b/file_resubmit/widgets.py @@ -23,9 +23,10 @@ def value_from_datadict(self, data, files, name): return upload self.input_name = "%s_cache_key" % name - self.cache_key = data.get(self.input_name, "") + if not self.cache_key: + self.cache_key = data.get(self.input_name, "") - if name in files: + if name in files and not self.cache_key: self.cache_key = self.random_key()[:10] upload = files[name] FileCache().set(self.cache_key, upload) From 11760ae0d7f0af39cd336e18cb407af0c6e647d1 Mon Sep 17 00:00:00 2001 From: Ernesto Revilla Date: Tue, 10 Mar 2020 20:08:32 +0100 Subject: [PATCH 2/2] Add span to text and class + id to widget. See #31 --- file_resubmit/widgets.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/file_resubmit/widgets.py b/file_resubmit/widgets.py index 5ceffed..afd698c 100644 --- a/file_resubmit/widgets.py +++ b/file_resubmit/widgets.py @@ -43,12 +43,13 @@ def random_key(self): def output_extra_data(self, value): output = '' if value and self.cache_key: - output += ' ' + self.filename_from_value(value) + output += ' ' + self.filename_from_value(value) + '' if self.cache_key: output += forms.HiddenInput().render( self.input_name, self.cache_key, - {}, + {'class': 'resubmit-hidden-input', + 'id': 'id_' + self.input_name}, ) return output