1 from django.contrib import admin
2 from django import forms
3 from django.template import Template as DjangoTemplate
4 from philo.admin import widgets
5 from philo.admin.base import COLLAPSE_CLASSES
6 from philo.admin.nodes import ViewAdmin
7 from philo.models.pages import Page, Template, Contentlet, ContentReference
8 from philo.forms import TemplateForm, ContentletInlineFormSet, ContentReferenceInlineFormSet, ContentletForm, ContentReferenceForm
11 class ContentletInline(admin.StackedInline):
15 formset = ContentletInlineFormSet
18 template = 'admin/philo/edit_inline/tabular_container.html'
21 class ContentReferenceInline(admin.StackedInline):
22 model = ContentReference
25 formset = ContentReferenceInlineFormSet
26 form = ContentReferenceForm
28 template = 'admin/philo/edit_inline/tabular_container.html'
31 class PageAdmin(ViewAdmin):
32 add_form_template = 'admin/philo/page/add_form.html'
35 'fields': ('title', 'template')
38 list_display = ('title', 'template')
39 list_filter = ('template',)
40 search_fields = ['title', 'contentlets__content']
41 inlines = [ContentletInline, ContentReferenceInline] + ViewAdmin.inlines
44 class TemplateAdmin(admin.ModelAdmin):
45 prepopulated_fields = {'slug': ('name',)}
48 'fields': ('parent', 'name', 'slug')
51 'classes': COLLAPSE_CLASSES,
52 'fields': ('documentation',)
58 'classes': COLLAPSE_CLASSES,
59 'fields': ('mimetype',)
64 list_display = ('__unicode__', 'slug', 'get_path',)
68 admin.site.register(Page, PageAdmin)
69 admin.site.register(Template, TemplateAdmin)