From: Guillaume Pellerin Date: Thu, 25 Jan 2018 23:05:54 +0000 (+0100) Subject: Test before save X-Git-Tag: 1.2~10^2~11 X-Git-Url: https://git.parisson.com/?a=commitdiff_plain;h=310244ae46e861574cb0e75092ed37cebd3eda7d;p=teleforma.git Test before save --- 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'