From: Radek Czajka Date: Mon, 23 Nov 2015 14:42:25 +0000 (+0100) Subject: Fix for unclickable cites in admin. X-Git-Url: https://git.mdrn.pl/wolnelektury.git/commitdiff_plain/013ec8a416d4ff1ea3e1f2fa9ee2935623197ecd?hp=f82c33291d3bf97d7447aba236940bdfe560f703 Fix for unclickable cites in admin. --- diff --git a/apps/social/admin.py b/apps/social/admin.py index 01b4c6578..3da4ae8c0 100755 --- a/apps/social/admin.py +++ b/apps/social/admin.py @@ -9,7 +9,7 @@ from social.models import Cite class CiteAdmin(admin.ModelAdmin): - list_display = ['text', 'sticky', 'vip', 'small', 'has_image'] + list_display = ['nonempty_text', 'sticky', 'vip', 'small', 'has_image'] fieldsets = ( (None, {'fields': ('book', 'text', 'small', 'vip', 'link', 'sticky')}), ( @@ -20,9 +20,15 @@ class CiteAdmin(admin.ModelAdmin): ) ) + def nonempty_text(self, cite): + if cite.text.strip(): + return cite.text + return "(%s)" % (cite.image_title.strip() or cite.link) + nonempty_text.short_description = _('text') + def has_image(self, cite): return bool(cite.image) - has_image.description = _('image') + has_image.short_description = _('image') has_image.boolean = True