1 from django.contrib import admin
2 from philo.admin.base import EntityAdmin, TreeEntityAdmin, COLLAPSE_CLASSES
3 from philo.models import Node, Redirect, File
4 from mptt.admin import MPTTModelAdmin
7 class NodeAdmin(TreeEntityAdmin):
8 list_display = ('slug', 'view', 'accepts_subpath')
9 raw_id_fields = ('parent',)
10 related_lookup_fields = {
13 'generic': [['view_content_type', 'view_object_id']]
16 def accepts_subpath(self, obj):
17 return obj.accepts_subpath
18 accepts_subpath.boolean = True
20 def formfield_for_foreignkey(self, db_field, request, **kwargs):
21 return super(MPTTModelAdmin, self).formfield_for_foreignkey(db_field, request, **kwargs)
24 class ViewAdmin(EntityAdmin):
28 class RedirectAdmin(ViewAdmin):
31 'fields': ('target_node', 'url_or_subpath', 'status_code')
34 'fields': ('reversing_parameters',),
35 'classes': COLLAPSE_CLASSES
38 list_display = ('target_url', 'status_code', 'target_node', 'url_or_subpath')
39 list_filter = ('status_code',)
40 raw_id_fields = ['target_node']
41 related_lookup_fields = {
46 class FileAdmin(ViewAdmin):
49 'fields': ('file', 'mimetype')
52 list_display = ('mimetype', 'file')
55 admin.site.register(Node, NodeAdmin)
56 admin.site.register(Redirect, RedirectAdmin)
57 admin.site.register(File, FileAdmin)