1
0
mirror of https://gitlab.crans.org/mediatek/med.git synced 2024-12-25 05:42:24 +00:00

Use media str method for admin

This commit is contained in:
Alexandre Iooss 2019-08-15 11:37:10 +02:00
parent 04c00fd5d0
commit 626990b119
No known key found for this signature in database
GPG Key ID: 6C79278F3FCDCC02
2 changed files with 5 additions and 11 deletions

View File

@ -18,7 +18,7 @@ class AuteurAdmin(VersionAdmin):
class MediaAdmin(VersionAdmin):
list_display = ('full_name', 'authors_list', 'side_identifier', 'isbn',
list_display = ('__str__', 'authors_list', 'side_identifier', 'isbn',
'external_link')
search_fields = ('title', 'authors__nom', 'side_identifier', 'subtitle',
'isbn')
@ -26,14 +26,6 @@ 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()])

View File

@ -63,8 +63,10 @@ class Media(models.Model):
)
def __str__(self):
return str(self.title) + ' - ' + str(self.subtitle) \
+ ' - ' + str(self.authors.all().first())
if self.subtitle:
return "{} : {}".format(self.title, self.subtitle)
else:
return self.title
class Meta:
verbose_name = _("medium")