X-Git-Url: https://git.mdrn.pl/redakcja.git/blobdiff_plain/9a3f21550b892b737e156797c4d6645bf1237085..181848c12143b7a9160b8bb33c8c69cbd48864a2:/src/catalogue/admin.py diff --git a/src/catalogue/admin.py b/src/catalogue/admin.py index e4574e38..2cab170c 100644 --- a/src/catalogue/admin.py +++ b/src/catalogue/admin.py @@ -105,7 +105,7 @@ class BookAdmin(WikidataAdminMixin, NumericFilterModelAdmin): LicenseFilter, CoverLicenseFilter, ] - readonly_fields = ["wikidata_link", "estimated_costs"] + readonly_fields = ["wikidata_link", "estimated_costs", "documents_book_link"] actions = [export_as_csv_action()] fieldsets = [ (None, {"fields": [("wikidata", "wikidata_link")]}), @@ -114,7 +114,7 @@ class BookAdmin(WikidataAdminMixin, NumericFilterModelAdmin): { "fields": [ "title", - "slug", + ("slug", 'documents_book_link'), "authors", "translators", "language", @@ -177,7 +177,12 @@ class BookAdmin(WikidataAdminMixin, NumericFilterModelAdmin): return '---' smart_title.short_description = _('Title') smart_title.admin_order_field = 'title' - + + def documents_book_link(self, obj): + for book in obj.document_books.all(): + return mark_safe(''.format(book.get_absolute_url(), book.slug)) + documents_book_link.short_description = _('Book') + admin.site.register(models.Book, BookAdmin)