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, BookMedia
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', 'created_at', 'has_pdf_file', 'has_epub_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 MediaAdmin(admin.ModelAdmin):
39 #tag_model = BookMedia
41 list_display = ('type', 'name')
42 ordering = ('type', 'name')
46 admin.site.register(Tag, TagAdmin)
47 admin.site.register(Book, BookAdmin)
48 admin.site.register(Fragment, FragmentAdmin)
49 admin.site.register(BookMedia, MediaAdmin)