From 90b6ca1350fbb780696434cb8381d3ab8f859979 Mon Sep 17 00:00:00 2001 From: Radek Czajka Date: Mon, 4 Apr 2022 12:26:51 +0200 Subject: [PATCH 1/1] Catalogue: sorting and searching. --- src/catalogue/admin.py | 7 ++++++- src/catalogue/models.py | 2 ++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/catalogue/admin.py b/src/catalogue/admin.py index 8ce330ce..3e80557d 100644 --- a/src/catalogue/admin.py +++ b/src/catalogue/admin.py @@ -40,7 +40,12 @@ class BookAdmin(WikidataAdminMixin, NumericFilterModelAdmin): "priority", "wikidata_link", ] - search_fields = ["title", "wikidata", "authors__first_name", "authors__last_name", "translators__first_name", "translators__last_name"] + search_fields = [ + "title", "wikidata", + "authors__first_name", "authors__last_name", + "translators__first_name", "translators__last_name", + "scans_source", "text_source", "notes", "estimate_source", + ] autocomplete_fields = ["authors", "translators", "based_on", "collections", "epochs", "genres", "kinds"] prepopulated_fields = {"slug": ("title",)} list_filter = [ diff --git a/src/catalogue/models.py b/src/catalogue/models.py index 2ceb110b..45250bcf 100644 --- a/src/catalogue/models.py +++ b/src/catalogue/models.py @@ -163,9 +163,11 @@ class Book(WikidataMixin, models.Model): def authors_str(self): return ", ".join(str(author) for author in self.authors.all()) + authors_str.admin_order_field = 'authors__last_name' def translators_str(self): return ", ".join(str(author) for author in self.translators.all()) + translators_str.admin_order_field = 'translators__last_name' def get_estimated_costs(self): return { -- 2.20.1