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):
|
class MediaAdmin(VersionAdmin):
|
||||||
list_display = ('full_name', 'authors_list', 'side_identifier', 'isbn',
|
list_display = ('__str__', 'authors_list', 'side_identifier', 'isbn',
|
||||||
'external_link')
|
'external_link')
|
||||||
search_fields = ('title', 'authors__nom', 'side_identifier', 'subtitle',
|
search_fields = ('title', 'authors__nom', 'side_identifier', 'subtitle',
|
||||||
'isbn')
|
'isbn')
|
||||||
|
@ -26,14 +26,6 @@ class MediaAdmin(VersionAdmin):
|
||||||
date_hierarchy = 'publish_date'
|
date_hierarchy = 'publish_date'
|
||||||
form = MediaAdminForm
|
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):
|
def authors_list(self, obj):
|
||||||
return ", ".join([a.nom for a in obj.authors.all()])
|
return ", ".join([a.nom for a in obj.authors.all()])
|
||||||
|
|
||||||
|
|
|
@ -63,8 +63,10 @@ class Media(models.Model):
|
||||||
)
|
)
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return str(self.title) + ' - ' + str(self.subtitle) \
|
if self.subtitle:
|
||||||
+ ' - ' + str(self.authors.all().first())
|
return "{} : {}".format(self.title, self.subtitle)
|
||||||
|
else:
|
||||||
|
return self.title
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
verbose_name = _("medium")
|
verbose_name = _("medium")
|
||||||
|
|
Loading…
Reference in New Issue