From 310244ae46e861574cb0e75092ed37cebd3eda7d Mon Sep 17 00:00:00 2001 From: Guillaume Pellerin Date: Fri, 26 Jan 2018 00:05:54 +0100 Subject: [PATCH] Test before save --- teleforma/exam/models.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/teleforma/exam/models.py b/teleforma/exam/models.py index 4cb8cf0d..d4bf2384 100644 --- a/teleforma/exam/models.py +++ b/teleforma/exam/models.py @@ -481,15 +481,22 @@ class Script(BaseResource): def set_file_properties(sender, instance, **kwargs): if instance.file: + trig_save = False if not instance.mime_type: instance.mime_type = mimetype_file(instance.file.path) + trig_save = True if not instance.sha1: instance.sha1 = sha1sum_file(instance.file.path) + trig_save = True if not instance.url: instance.uuid_link() + trig_save = True if not instance.corrector: instance.submit() - super(sender, instance).save() + trig_save = True + if trig_save: + super(sender, instance).save() + # if hasattr(instance, 'image'): # if not instance.image: # path = cache_path + os.sep + instance.uuid + '.jpg' -- 2.39.5