]> git.parisson.com Git - mezzo.git/commitdiff
Full media update, not only on creation (fix #135)
authorGuillaume Pellerin <guillaume.pellerin@ircam.fr>
Mon, 27 Feb 2017 10:01:47 +0000 (11:01 +0100)
committerGuillaume Pellerin <guillaume.pellerin@ircam.fr>
Mon, 27 Feb 2017 10:01:47 +0000 (11:01 +0100)
app/organization/media/models.py
docker-compose.yml

index 404e9e968e54714e2bdc061677d57563e12086c5..640d37962fe41d69c6c9be1a5776a1f134597d12 100644 (file)
@@ -79,30 +79,21 @@ class Media(Displayable):
             if 'audio' in transcoded.mime_type:
                 return 'audio'
 
-
-def create_media(instance, created, raw, **kwargs):
-    # Ignore fixtures and saves for existing courses.
-
-    if not created or raw:
-        return
-
-    q = pq(instance.get_html())
-    sources = q('source')
-
-    video = q('video')
-    if len(video):
-        if 'poster' in video[0].attrib.keys():
-            instance.poster_url = video[0].attrib['poster']
-
-    for source in sources:
-        mime_type = source.attrib['type']
-        transcoded = MediaTranscoded(media=instance, mime_type=mime_type)
-        transcoded.url = source.attrib['src']
-        transcoded.save()
-
-    instance.save()
-
-models.signals.post_save.connect(create_media, sender=Media, dispatch_uid='create_media')
+    def save(self, *args, **kwargs):
+        q = pq(self.get_html())
+        sources = q('source')
+        video = q('video')
+        if len(video):
+            if 'poster' in video[0].attrib.keys():
+                self.poster_url = video[0].attrib['poster']
+
+        super(Media, self).save(*args, **kwargs)
+
+        for source in sources:
+            mime_type = source.attrib['type']
+            transcoded, c = MediaTranscoded.objects.get_or_create(media=self, mime_type=mime_type)
+            transcoded.url = source.attrib['src']
+            transcoded.save()
 
 
 class MediaTranscoded(models.Model):
index 0e74afc79a99eae071b85414a9cef579cca9b927..c47f64df5ee5e432884f924ec1c6907e12e3e29a 100644 (file)
@@ -71,3 +71,19 @@ nginx:
     - var
   links:
     - app
+
+cron:
+  image: panubo/cron
+  volumes:
+    - ./etc/crontab:/crontab
+  volumes_from:
+    - var
+    - app
+    - db
+  links:
+    - app
+    - db
+  environment:
+    - TZ=Europe/Paris
+    - SMTP_HOST=smtp.ircam.fr
+    - SMTP_PORT=25