From 619878b2f600db024eef33ef0a94a9c2ebde3fd0 Mon Sep 17 00:00:00 2001 From: Enno Lohmeier Date: Thu, 5 Jul 2018 12:56:20 +0200 Subject: [PATCH 1/2] add document count column for tags and correspondents --- src/documents/admin.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/documents/admin.py b/src/documents/admin.py index 39524ae21..2727c7704 100644 --- a/src/documents/admin.py +++ b/src/documents/admin.py @@ -105,17 +105,23 @@ class CommonAdmin(admin.ModelAdmin): class CorrespondentAdmin(CommonAdmin): - list_display = ("name", "match", "matching_algorithm") + list_display = ("name", "match", "matching_algorithm", "document_count") list_filter = ("matching_algorithm",) list_editable = ("match", "matching_algorithm") + def document_count(self, obj): + return obj.documents.count() + class TagAdmin(CommonAdmin): - list_display = ("name", "colour", "match", "matching_algorithm") + list_display = ("name", "colour", "match", "matching_algorithm", "document_count") list_filter = ("colour", "matching_algorithm") list_editable = ("colour", "match", "matching_algorithm") + def document_count(self, obj): + return obj.documents.count() + class DocumentAdmin(CommonAdmin): From 2894d105cbb963d3889750d3af0e6cbec9b04c27 Mon Sep 17 00:00:00 2001 From: Enno Lohmeier Date: Thu, 5 Jul 2018 13:10:08 +0200 Subject: [PATCH 2/2] fix code style issue --- src/documents/admin.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/documents/admin.py b/src/documents/admin.py index 2727c7704..659ad8581 100644 --- a/src/documents/admin.py +++ b/src/documents/admin.py @@ -115,7 +115,8 @@ def document_count(self, obj): class TagAdmin(CommonAdmin): - list_display = ("name", "colour", "match", "matching_algorithm", "document_count") + list_display = ("name", "colour", "match", "matching_algorithm", + "document_count") list_filter = ("colour", "matching_algorithm") list_editable = ("colour", "match", "matching_algorithm")