]> git.parisson.com Git - teleforma.git/commitdiff
Test before save
authorGuillaume Pellerin <guillaume.pellerin@ircam.fr>
Thu, 25 Jan 2018 23:05:54 +0000 (00:05 +0100)
committerGuillaume Pellerin <guillaume.pellerin@ircam.fr>
Thu, 25 Jan 2018 23:05:54 +0000 (00:05 +0100)
teleforma/exam/models.py

index 4cb8cf0df75bc437d458ab5be04cde707e44ed16..d4bf238480b58c1465c68f365a5b29086b6ce8d2 100644 (file)
@@ -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'