1 from django.contrib import admin
3 from .wikidata import WikidataAdminMixin
6 class AuthorAdmin(WikidataAdminMixin, admin.ModelAdmin):
7 list_display = ["first_name", "last_name", 'status', "year_of_death", "priority", "wikidata_link"]
8 list_filter = ['year_of_death', 'priority', 'collections', 'status']
9 search_fields = ["first_name", "last_name", "wikidata"]
10 prepopulated_fields = {"slug": ("first_name", "last_name")}
11 autocomplete_fields = ['collections']
14 admin.site.register(models.Author, AuthorAdmin)
17 class BookAdmin(WikidataAdminMixin, admin.ModelAdmin):
18 list_display = ["title", 'authors_str', 'translators_str', 'language', 'pd_year', 'priority', 'wikidata_link']
19 search_fields = ["title", 'wikidata']
20 autocomplete_fields = ["authors", "translators", "based_on", 'collections']
21 prepopulated_fields = {"slug": ("title",)}
22 list_filter = ['language', 'pd_year', 'collections']
23 readonly_fields = ['wikidata_link']
26 ('wikidata', 'wikidata_link'),
28 ('Identification', {'fields': [
29 'title', 'slug', 'authors', 'translators', 'language',
43 admin.site.register(models.Book, BookAdmin)
46 class AuthorInline(admin.TabularInline):
47 model = models.Author.collections.through
48 autocomplete_fields = ['author']
51 class BookInline(admin.TabularInline):
52 model = models.Book.collections.through
53 autocomplete_fields = ['book']
56 class CollectionAdmin(admin.ModelAdmin):
57 list_display = ['name']
58 autocomplete_fields = []
59 prepopulated_fields = {'slug': ('name',)}
60 search_fields = ['name']
61 inlines = [AuthorInline, BookInline]
63 admin.site.register(models.Collection, CollectionAdmin)