from django.contrib import admin
from philo.admin.base import EntityAdmin, TreeEntityAdmin, COLLAPSE_CLASSES
-from philo.models import Node, Redirect, File, NodeNavigationOverride
-from philo.forms import NodeWithOverrideForm
-
-
-class ChildNavigationOverrideInline(admin.StackedInline):
- fk_name = 'parent'
- model = NodeNavigationOverride
- sortable_field_name = 'order'
- verbose_name = 'child'
- verbose_name_plural = 'children'
- extra = 0
- max_num = 0
+from philo.models import Node, Redirect, File
+from mptt.admin import MPTTModelAdmin
class NodeAdmin(TreeEntityAdmin):
- form = NodeWithOverrideForm
- fieldsets = (
- (None, {
- 'fields': ('parent', 'slug', 'view_content_type', 'view_object_id'),
- }),
- ('Navigation Overrides', {
- 'fields': ('title', 'url', 'child_navigation'),
- 'classes': COLLAPSE_CLASSES
- })
- )
- inlines = [ChildNavigationOverrideInline] + TreeEntityAdmin.inlines
+ list_display = ('slug', 'view', 'accepts_subpath')
+ raw_id_fields = ('parent',)
+ related_lookup_fields = {
+ 'fk': raw_id_fields,
+ 'm2m': [],
+ 'generic': [['view_content_type', 'view_object_id']]
+ }
+
+ def accepts_subpath(self, obj):
+ return obj.accepts_subpath
+ accepts_subpath.boolean = True
+
+ def formfield_for_foreignkey(self, db_field, request, **kwargs):
+ return super(MPTTModelAdmin, self).formfield_for_foreignkey(db_field, request, **kwargs)
class ViewAdmin(EntityAdmin):
class RedirectAdmin(ViewAdmin):
fieldsets = (
(None, {
- 'fields': ('target', 'status_code')
+ 'fields': ('target_node', 'url_or_subpath', 'status_code')
}),
+ ('Advanced', {
+ 'fields': ('reversing_parameters',),
+ 'classes': COLLAPSE_CLASSES
+ })
)
- list_display = ('target', 'status_code')
+ list_display = ('target_url', 'status_code', 'target_node', 'url_or_subpath')
list_filter = ('status_code',)
+ raw_id_fields = ['target_node']
+ related_lookup_fields = {
+ 'fk': raw_id_fields
+ }
class FileAdmin(ViewAdmin):