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:
parent
04c00fd5d0
commit
626990b119
@ -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()])
|
||||
|
||||
|
@ -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")
|
||||
|
Loading…
Reference in New Issue
Block a user