Files
vrobbler/vrobbler/apps/books/admin.py
Colin Powell 102494ede7
All checks were successful
build / test (push) Successful in 1m55s
[admin] Use raw ids where possible and simplify scrobble inlines
2026-06-15 13:25:10 -04:00

57 lines
1.2 KiB
Python

from books.models import Author, Book, Paper
from django.contrib import admin
from scrobbles.admin import ScrobbleInline
@admin.register(Author)
class AuthorAdmin(admin.ModelAdmin):
date_hierarchy = "created"
list_display = (
"name",
"openlibrary_id",
"bio",
"wikipedia_url",
)
ordering = ("-created",)
search_fields = ("name",)
@admin.register(Book)
class BookAdmin(admin.ModelAdmin):
date_hierarchy = "created"
list_display = (
"title",
"author",
"issue_or_volume",
"isbn_13",
"first_publish_year",
"pages",
)
raw_id_fields = ("authors",)
search_fields = ("name",)
ordering = ("-created",)
inlines = [
ScrobbleInline,
]
def issue_or_volume(self, obj):
return obj.subtitle
@admin.register(Paper)
class PaperAdmin(admin.ModelAdmin):
date_hierarchy = "created"
list_display = (
"title",
"subtitle",
"arxiv_id",
"first_publish_year",
"pages",
)
raw_id_fields = ("authors",)
search_fields = ("name",)
ordering = ("-created",)
inlines = [
ScrobbleInline,
]