Add subtitle to admin

This commit is contained in:
Alexandre Iooss 2019-08-11 23:46:09 +02:00
parent 7d94609f9b
commit 07c21b9c79
No known key found for this signature in database
GPG Key ID: 6C79278F3FCDCC02
1 changed files with 9 additions and 1 deletions

View File

@ -18,7 +18,7 @@ class AuteurAdmin(VersionAdmin):
class MediaAdmin(VersionAdmin):
list_display = ('title', 'authors_list', 'side_identifier', 'isbn',
list_display = ('full_name', 'authors_list', 'side_identifier', 'isbn',
'external_link')
search_fields = ('title', 'authors__nom', 'side_identifier', 'subtitle',
'isbn')
@ -26,6 +26,14 @@ class MediaAdmin(VersionAdmin):
date_hierarchy = 'publish_date'
form = MediaAdminForm
def full_name(self, obj):
if obj.subtitle:
return "{} : {}".format(obj.title, obj.subtitle)
else:
return obj.title
full_name.short_description = _('name')
def authors_list(self, obj):
return ", ".join([a.nom for a in obj.authors.all()])