From f3a2763e141021c709214df2a248d49cca68eb55 Mon Sep 17 00:00:00 2001 From: yomguy Date: Fri, 14 Dec 2012 15:39:21 +0100 Subject: [PATCH] fix media str --- teleforma/admin.py | 1 + teleforma/models/core.py | 15 ++++++++------- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/teleforma/admin.py b/teleforma/admin.py index f5f32fa0..12145d27 100644 --- a/teleforma/admin.py +++ b/teleforma/admin.py @@ -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'] diff --git a/teleforma/models/core.py b/teleforma/models/core.py index 1be172ec..ad6a7d41 100644 --- a/teleforma/models/core.py +++ b/teleforma/models/core.py @@ -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) -- 2.39.5