1 from django.conf import settings
2 from django.contrib import admin
3 from django import forms
4 from philo.admin.base import COLLAPSE_CLASSES, TreeAdmin
5 from philo.admin.nodes import ViewAdmin
6 from philo.models.pages import Page, Template, Contentlet, ContentReference
7 from philo.admin.forms.containers import *
10 class ContentletInline(admin.StackedInline):
14 formset = ContentletInlineFormSet
17 classes = ('collapse-open', 'collapse','open')
18 if 'grappelli' in settings.INSTALLED_APPS:
19 template = 'admin/philo/edit_inline/grappelli_tabular_container.html'
21 template = 'admin/philo/edit_inline/tabular_container.html'
24 class ContentReferenceInline(admin.StackedInline):
25 model = ContentReference
28 formset = ContentReferenceInlineFormSet
29 form = ContentReferenceForm
31 classes = ('collapse-open', 'collapse','open')
32 if 'grappelli' in settings.INSTALLED_APPS:
33 template = 'admin/philo/edit_inline/grappelli_tabular_container.html'
35 template = 'admin/philo/edit_inline/tabular_container.html'
38 class PageAdmin(ViewAdmin):
39 add_form_template = 'admin/philo/page/add_form.html'
42 'fields': ('title', 'template')
45 list_display = ('title', 'template')
46 list_filter = ('template',)
47 search_fields = ['title', 'contentlets__content']
48 inlines = [ContentletInline, ContentReferenceInline] + ViewAdmin.inlines
51 class TemplateAdmin(TreeAdmin):
52 prepopulated_fields = {'slug': ('name',)}
55 'fields': ('parent', 'name', 'slug')
58 'classes': COLLAPSE_CLASSES,
59 'fields': ('documentation',)
65 'classes': COLLAPSE_CLASSES,
66 'fields': ('mimetype',)
71 list_display = ('__unicode__', 'slug', 'get_path',)
74 admin.site.register(Page, PageAdmin)
75 admin.site.register(Template, TemplateAdmin)