add "has file" column

This commit is contained in:
Tomáš Mládek 2020-04-14 15:34:24 +02:00
parent e724748a5f
commit 757f30b53c

View file

@ -33,11 +33,16 @@ class DocumentExternalListFilter(admin.SimpleListFilter):
class DocumentAdmin(admin.ModelAdmin):
exclude = ('is_removed',)
list_display = ('title', 'author', 'published', 'public', 'filed_under')
list_display = ('title', 'author', 'published', 'has_file', 'public', 'filed_under')
list_filter = ('tags', 'public', DocumentExternalListFilter)
search_fields = ('title', 'author', 'published')
actions = ('make_published', 'make_hidden')
def has_file(self, document: Document):
return document.file is not None and document.file != ''
has_file.boolean = True
@staticmethod
def filed_under(document: Document):
return ", ".join(tag.name for tag in document.tags.all())