fnp
/
redakcja.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
9a3f215
)
Catalogue: link document.
author
Radek Czajka
<rczajka@rczajka.pl>
Mon, 4 Apr 2022 11:24:05 +0000
(13:24 +0200)
committer
Radek Czajka
<rczajka@rczajka.pl>
Mon, 4 Apr 2022 11:24:05 +0000
(13:24 +0200)
src/catalogue/admin.py
patch
|
blob
|
history
diff --git
a/src/catalogue/admin.py
b/src/catalogue/admin.py
index
e4574e3
..
2cab170
100644
(file)
--- a/
src/catalogue/admin.py
+++ b/
src/catalogue/admin.py
@@
-105,7
+105,7
@@
class BookAdmin(WikidataAdminMixin, NumericFilterModelAdmin):
LicenseFilter,
CoverLicenseFilter,
]
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")]}),
actions = [export_as_csv_action()]
fieldsets = [
(None, {"fields": [("wikidata", "wikidata_link")]}),
@@
-114,7
+114,7
@@
class BookAdmin(WikidataAdminMixin, NumericFilterModelAdmin):
{
"fields": [
"title",
{
"fields": [
"title",
-
"slug"
,
+
("slug", 'documents_book_link')
,
"authors",
"translators",
"language",
"authors",
"translators",
"language",
@@
-177,7
+177,12
@@
class BookAdmin(WikidataAdminMixin, NumericFilterModelAdmin):
return '---'
smart_title.short_description = _('Title')
smart_title.admin_order_field = 'title'
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('<a style="position: absolute" href="{}"><img height="100" width="70" src="/cover/preview/{}/?height=100&width=70"></a>'.format(book.get_absolute_url(), book.slug))
+ documents_book_link.short_description = _('Book')
+
admin.site.register(models.Book, BookAdmin)
admin.site.register(models.Book, BookAdmin)