From 622862bc33b5e1ad606ed57681c18d40f3e38fe7 Mon Sep 17 00:00:00 2001 From: Radek Czajka Date: Fri, 4 Nov 2022 10:51:41 +0100 Subject: [PATCH] Export authors names in CSV. --- src/catalogue/admin.py | 6 ++++-- src/catalogue/models.py | 12 ++++++++++++ 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/src/catalogue/admin.py b/src/catalogue/admin.py index 958230b4..96af8c13 100644 --- a/src/catalogue/admin.py +++ b/src/catalogue/admin.py @@ -187,8 +187,10 @@ class BookAdmin(WikidataAdminMixin, NumericFilterModelAdmin): "wikidata", "slug", "title", - "authors_str", # authors? - "translators_str", # translators? + "authors_first_names", + "authors_last_names", + "translators_first_names", + "translators_last_names", "language", "based_on", "scans_source", diff --git a/src/catalogue/models.py b/src/catalogue/models.py index 4544fc68..d3766d5a 100644 --- a/src/catalogue/models.py +++ b/src/catalogue/models.py @@ -236,6 +236,18 @@ class Book(WikidataModel): translators_str.admin_order_field = 'translators__last_name' translators_str.short_description = _('Translator') + def authors_first_names(self): + return ', '.join(a.first_name for a in self.authors.all()) + + def authors_last_names(self): + return ', '.join(a.last_name for a in self.authors.all()) + + def translators_first_names(self): + return ', '.join(a.first_name for a in self.translators.all()) + + def translators_last_names(self): + return ', '.join(a.last_name for a in self.translators.all()) + def get_estimated_costs(self): return { work_type: work_type.calculate(self) -- 2.20.1