From: yomguy Date: Fri, 14 Dec 2012 14:39:21 +0000 (+0100) Subject: fix media str X-Git-Tag: 0.9-probarreau~254 X-Git-Url: https://git.parisson.com/?a=commitdiff_plain;h=f3a2763e141021c709214df2a248d49cca68eb55;p=teleforma.git fix media str --- 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)