Export authors names in CSV.
authorRadek Czajka <rczajka@rczajka.pl>
Fri, 4 Nov 2022 09:51:41 +0000 (10:51 +0100)
committerRadek Czajka <rczajka@rczajka.pl>
Fri, 4 Nov 2022 09:51:41 +0000 (10:51 +0100)
src/catalogue/admin.py
src/catalogue/models.py

index 958230b..96af8c1 100644 (file)
@@ -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",
index 4544fc6..d3766d5 100644 (file)
@@ -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)