forked from rc/aircox
names & conditional display of audio in admin
This commit is contained in:
@ -45,7 +45,7 @@ class SoundAdmin(SortableAdminBase, admin.ModelAdmin):
|
||||
'type', 'duration', 'is_public', 'is_good_quality',
|
||||
'is_downloadable', 'audio']
|
||||
list_filter = ('type', 'is_good_quality', 'is_public')
|
||||
list_editable = ['name', 'type', 'is_public', 'is_downloadable']
|
||||
list_editable = ['name', 'is_public', 'is_downloadable']
|
||||
|
||||
search_fields = ['name', 'program__title']
|
||||
fieldsets = [
|
||||
@ -53,7 +53,7 @@ class SoundAdmin(SortableAdminBase, admin.ModelAdmin):
|
||||
(None, {'fields': ['duration', 'is_public', 'is_downloadable',
|
||||
'is_good_quality', 'mtime']}),
|
||||
]
|
||||
readonly_fields = ('file', 'duration',)
|
||||
readonly_fields = ('file', 'duration', 'type')
|
||||
inlines = [SoundTrackInline]
|
||||
|
||||
def related(self, obj):
|
||||
@ -63,7 +63,8 @@ class SoundAdmin(SortableAdminBase, admin.ModelAdmin):
|
||||
related.short_description = _('Program / Episode')
|
||||
|
||||
def audio(self, obj):
|
||||
return mark_safe('<audio src="{}" controls></audio>'.format(obj.file.url))
|
||||
return mark_safe('<audio src="{}" controls></audio>'.format(obj.file.url)) \
|
||||
if obj.type != Sound.TYPE_REMOVED else ''
|
||||
audio.short_description = _('Audio')
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user