1 from django.contrib import admin
2 from philo.admin import TreeEntityAdmin, COLLAPSE_CLASSES, NodeAdmin
3 from philo.contrib.navigation.models import Navigation
6 NAVIGATION_RAW_ID_FIELDS = ('hosting_node', 'parent', 'target_node')
9 class NavigationInline(admin.StackedInline):
15 'fields': ('target_node', 'url_or_subpath',)
18 'fields': ('reversing_parameters', 'order', 'depth'),
19 'classes': COLLAPSE_CLASSES
22 'fields': ('hosting_node', 'parent'),
23 'classes': COLLAPSE_CLASSES
26 raw_id_fields = NAVIGATION_RAW_ID_FIELDS
29 sortable_field_name = 'order'
32 class NavigationNavigationInline(NavigationInline):
33 verbose_name = "child"
34 verbose_name_plural = "children"
37 class NodeNavigationInline(NavigationInline):
38 verbose_name_plural = 'navigation'
41 class NavigationAdmin(TreeEntityAdmin):
42 list_display = ('__unicode__', 'target_node', 'url_or_subpath', 'reversing_parameters')
45 'fields': ('text', 'hosting_node',)
48 'fields': ('target_node', 'url_or_subpath',)
51 'fields': ('reversing_parameters', 'depth'),
52 'classes': COLLAPSE_CLASSES
55 'fields': ('parent', 'order'),
56 'classes': COLLAPSE_CLASSES
59 raw_id_fields = NAVIGATION_RAW_ID_FIELDS
60 inlines = [NavigationNavigationInline] + TreeEntityAdmin.inlines
63 NodeAdmin.inlines = [NodeNavigationInline] + NodeAdmin.inlines
66 admin.site.register(Navigation, NavigationAdmin)