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):
44 'fields': ('text', 'hosting_node',)
47 'fields': ('target_node', 'url_or_subpath',)
50 'fields': ('reversing_parameters', 'depth'),
51 'classes': COLLAPSE_CLASSES
54 'fields': ('parent', 'order'),
55 'classes': COLLAPSE_CLASSES
58 raw_id_fields = NAVIGATION_RAW_ID_FIELDS
59 inlines = [NavigationNavigationInline] + TreeEntityAdmin.inlines
62 NodeAdmin.inlines = [NodeNavigationInline] + NodeAdmin.inlines
65 admin.site.register(Navigation, NavigationAdmin)