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 filter_horizontal = ('medias',)
30 def change_view(self, request, object_id, extra_context=None):
32 # 'osm_data': self.get_osm_info(),
34 print request.GET.keys()
35 if not request.GET.has_key('advanced'):
36 self.fields = ['title', 'description', 'gazeta_link', 'wiki_link', 'pdf_file', 'medias']
39 return super(BookAdmin, self).change_view(request, object_id,
40 extra_context=extra_context)
44 class FragmentAdmin(TaggableModelAdmin):
47 list_display = ('book', 'anchor',)
48 ordering = ('book', 'anchor',)
51 class MediaAdmin(admin.ModelAdmin):
52 #tag_model = BookMedia
54 list_display = ('name', 'type', 'uploaded_at')
55 ordering = ('name', 'type')
56 search_fields = ('name',)
60 admin.site.register(Tag, TagAdmin)
61 admin.site.register(Book, BookAdmin)
62 admin.site.register(Fragment, FragmentAdmin)
63 admin.site.register(BookMedia, MediaAdmin)