1 from django.contrib import admin
2 from mptt.admin import MPTTModelAdmin
4 from philo.admin.base import EntityAdmin, TreeEntityAdmin, COLLAPSE_CLASSES
5 from philo.models import Node, Redirect, File
8 class NodeAdmin(TreeEntityAdmin):
9 list_display = ('slug', 'view', 'accepts_subpath')
10 raw_id_fields = ('parent',)
11 related_lookup_fields = {
14 'generic': [['view_content_type', 'view_object_id']]
17 def accepts_subpath(self, obj):
18 return obj.accepts_subpath
19 accepts_subpath.boolean = True
21 def formfield_for_foreignkey(self, db_field, request, **kwargs):
22 return super(MPTTModelAdmin, self).formfield_for_foreignkey(db_field, request, **kwargs)
25 class ViewAdmin(EntityAdmin):
29 class RedirectAdmin(ViewAdmin):
32 'fields': ('target_node', 'url_or_subpath', 'status_code')
35 'fields': ('reversing_parameters',),
36 'classes': COLLAPSE_CLASSES
39 list_display = ('target_url', 'status_code', 'target_node', 'url_or_subpath')
40 list_filter = ('status_code',)
41 raw_id_fields = ['target_node']
42 related_lookup_fields = {
47 class FileAdmin(ViewAdmin):
50 'fields': ('file', 'mimetype')
53 list_display = ('mimetype', 'file')
56 admin.site.register(Node, NodeAdmin)
57 admin.site.register(Redirect, RedirectAdmin)
58 admin.site.register(File, FileAdmin)