]> git.parisson.com Git - mezzo.git/commitdiff
Fix absolute media url by adding a type property (Fix #114)
authorGuillaume Pellerin <guillaume.pellerin@ircam.fr>
Tue, 14 Feb 2017 13:07:55 +0000 (14:07 +0100)
committerGuillaume Pellerin <guillaume.pellerin@ircam.fr>
Tue, 14 Feb 2017 13:07:55 +0000 (14:07 +0100)
app/organization/media/models.py
app/organization/media/views.py
var

index 733903a917e9efa1db26f195663ba521783f3a76..182fea99f3d7c0a21208edf12a0eb2eacf500fba 100644 (file)
@@ -61,7 +61,7 @@ class Media(Displayable):
         return self.title
 
     def get_absolute_url(self):
-        return reverse("organization-media-detail", kwargs={"slug": self.slug})
+        return reverse("organization-media-detail", kwargs={"type": self.type, "slug": self.slug})
 
     @property
     def uri(self):
@@ -71,6 +71,14 @@ class Media(Displayable):
         r = requests.get(self.uri)
         return r.content
 
+    @property
+    def type(self):
+        for transcoded in self.transcoded.all():
+            if 'video' in transcoded.mime_type:
+                return 'video'
+            if 'audio' in transcoded.mime_type:
+                return 'audio'
+
 
 def create_media(instance, created, raw, **kwargs):
     # Ignore fixtures and saves for existing courses.
index d5bdd646038a1436fbe5d23d1ba10b0e27d4e793..ca0634c6be1656696bb4fd35059466e95c7bac67 100644 (file)
@@ -46,6 +46,7 @@ class PlaylistDetailView(SlugMixin, DetailView):
     model = Playlist
     template_name='media/playlist_detail.html'
     context_object_name = 'playlist'
+    
     def get_context_data(self, **kwargs):
         context = super(PlaylistDetailView, self).get_context_data(**kwargs)
         self.related_objects = []
diff --git a/var b/var
index a2000b490d33a260e9469c11fdd2bfc198d244c0..9a292ad53e9733951f585568d7c0efd9617e3619 160000 (submodule)
--- a/var
+++ b/var
@@ -1 +1 @@
-Subproject commit a2000b490d33a260e9469c11fdd2bfc198d244c0
+Subproject commit 9a292ad53e9733951f585568d7c0efd9617e3619