1 # -*- coding: utf-8 -*-
2 # This file is part of Wolnelektury, licensed under GNU Affero GPLv3 or later.
3 # Copyright © Fundacja Nowoczesna Polska. See NOTICE for more information.
5 from django.contrib import admin
7 from newtagging.admin import TaggableModelAdmin
8 from catalogue.models import Tag, Book, Fragment, BookStub
11 class TagAdmin(admin.ModelAdmin):
12 list_display = ('name', 'slug', 'sort_key', 'category', 'has_description', 'main_page',)
13 list_filter = ('category',)
14 search_fields = ('name',)
17 prepopulated_fields = {'slug': ('name',), 'sort_key': ('name',),}
18 radio_fields = {'category': admin.HORIZONTAL}
21 class BookAdmin(TaggableModelAdmin):
24 list_display = ('title', 'slug', 'has_pdf_file', 'has_epub_file', 'has_odt_file', 'has_html_file', 'has_description',)
25 search_fields = ('title',)
28 prepopulated_fields = {'slug': ('title',)}
31 class FragmentAdmin(TaggableModelAdmin):
34 list_display = ('book', 'anchor',)
35 ordering = ('book', 'anchor',)
38 class BookStubAdmin(admin.ModelAdmin):
41 list_display = ('title', 'author', 'slug','pd')
42 search_fields = ('title','author')
45 prepopulated_fields = {'slug': ('title',)}
48 admin.site.register(BookStub, BookStubAdmin)
49 admin.site.register(Tag, TagAdmin)
50 admin.site.register(Book, BookAdmin)
51 admin.site.register(Fragment, FragmentAdmin)