]> git.parisson.com Git - teleforma.git/commitdiff
fix media str
authoryomguy <yomguy@parisson.com>
Fri, 14 Dec 2012 14:39:21 +0000 (15:39 +0100)
committeryomguy <yomguy@parisson.com>
Fri, 14 Dec 2012 14:39:21 +0000 (15:39 +0100)
teleforma/admin.py
teleforma/models/core.py

index f5f32fa04629568805bd7fadbeddb9680a25d9ad..12145d275b6c8c268c78dd50907dd483ee719ac8 100644 (file)
@@ -59,6 +59,7 @@ class MediaAdmin(admin.ModelAdmin):
 class MediaPackageAdmin(admin.ModelAdmin):
     exclude = ['mime_type']
     search_fields = ['id']
+    filter_horizontal = ['video', 'audio']
 
 class ConferenceAdmin(admin.ModelAdmin):
     exclude = ['readers']
index 1be172ec02fbddbb2ed09578e284ff2dd64999aa..ad6a7d41fa5cdc35e47512a42d20c92b648ac93f 100644 (file)
@@ -486,23 +486,24 @@ class Media(MediaBase):
                 self.mime_type = 'audio/mp3'
             else:
                 self.mime_type = mime_type
-            self.save()
 
     def __unicode__(self):
-        if self.conference:
-            return self.conference.description
-        elif self.course and self.course_type:
-            return self.course.title + ' ' + self.course_type.name
+        strings = []
+        if self.course and self.course_type:
+            strings.append(self.course.code + ' ' + self.course_type.name)
         elif self.course:
-            return self.course.title
+            strings.append(self.course.code)
         else:
-            return self.item.file
+            strings.append(self.item.file)
+        strings.append(self.mime_type)
+        return ' - '.join(strings)
 
     def save(self, **kwargs):
         if self.course:
             self.course.save()
         elif self.conference:
             self.conference.course.save()
+        self.set_mime_type()
         super(Media, self).save(**kwargs)