from django.contrib import admin
-from philo.admin import TreeEntityAdmin, COLLAPSE_CLASSES, NodeAdmin
-from philo.contrib.shipherd.models import Navigation
+from philo.admin import TreeEntityAdmin, COLLAPSE_CLASSES, NodeAdmin, EntityAdmin
+from philo.models import Node
+from philo.contrib.shipherd.models import NavigationItem, Navigation
-NAVIGATION_RAW_ID_FIELDS = ('hosting_node', 'parent', 'target_node')
+NAVIGATION_RAW_ID_FIELDS = ('navigation', 'parent', 'target_node')
-class NavigationInline(admin.StackedInline):
+class NavigationItemInline(admin.StackedInline):
+ raw_id_fields = NAVIGATION_RAW_ID_FIELDS
+ model = NavigationItem
+ extra = 1
+ sortable_field_name = 'order'
+
+
+class NavigationItemChildInline(NavigationItemInline):
+ verbose_name = "child"
+ verbose_name_plural = "children"
fieldsets = (
(None, {
- 'fields': ('text',)
+ 'fields': ('text', 'parent')
}),
('Target', {
'fields': ('target_node', 'url_or_subpath',)
}),
('Advanced', {
- 'fields': ('reversing_parameters', 'order', 'depth'),
+ 'fields': ('reversing_parameters', 'order'),
'classes': COLLAPSE_CLASSES
+ })
+ )
+
+
+class NavigationNavigationItemInline(NavigationItemInline):
+ fieldsets = (
+ (None, {
+ 'fields': ('text', 'navigation')
}),
- ('Expert', {
- 'fields': ('hosting_node', 'parent'),
+ ('Target', {
+ 'fields': ('target_node', 'url_or_subpath',)
+ }),
+ ('Advanced', {
+ 'fields': ('reversing_parameters', 'order'),
'classes': COLLAPSE_CLASSES
})
)
- raw_id_fields = NAVIGATION_RAW_ID_FIELDS
- model = Navigation
- extra = 1
- sortable_field_name = 'order'
-class NavigationNavigationInline(NavigationInline):
- verbose_name = "child"
- verbose_name_plural = "children"
+class NodeNavigationItemInline(NavigationItemInline):
+ verbose_name_plural = 'targeting navigation'
+ fieldsets = (
+ (None, {
+ 'fields': ('text',)
+ }),
+ ('Target', {
+ 'fields': ('target_node', 'url_or_subpath',)
+ }),
+ ('Advanced', {
+ 'fields': ('reversing_parameters', 'order'),
+ 'classes': COLLAPSE_CLASSES
+ }),
+ ('Expert', {
+ 'fields': ('parent', 'navigation')
+ }),
+ )
+
+
+class NodeNavigationInline(admin.TabularInline):
+ model = Navigation
+ extra = 1
-class NodeNavigationInline(NavigationInline):
- verbose_name_plural = 'navigation'
+NodeAdmin.inlines = [NodeNavigationInline, NodeNavigationItemInline] + NodeAdmin.inlines
-class NavigationAdmin(TreeEntityAdmin):
+class NavigationItemAdmin(TreeEntityAdmin):
list_display = ('__unicode__', 'target_node', 'url_or_subpath', 'reversing_parameters')
fieldsets = (
(None, {
- 'fields': ('text', 'hosting_node',)
+ 'fields': ('text', 'navigation',)
}),
('Target', {
'fields': ('target_node', 'url_or_subpath',)
}),
('Advanced', {
- 'fields': ('reversing_parameters', 'depth'),
+ 'fields': ('reversing_parameters',),
'classes': COLLAPSE_CLASSES
}),
('Expert', {
})
)
raw_id_fields = NAVIGATION_RAW_ID_FIELDS
- inlines = [NavigationNavigationInline] + TreeEntityAdmin.inlines
+ inlines = [NavigationItemChildInline] + TreeEntityAdmin.inlines
-NodeAdmin.inlines = [NodeNavigationInline] + NodeAdmin.inlines
+class NavigationAdmin(EntityAdmin):
+ inlines = [NavigationNavigationItemInline]
+ raw_id_fields = ['node']
-admin.site.register(Navigation, NavigationAdmin)
\ No newline at end of file
+admin.site.unregister(Node)
+admin.site.register(Node, NodeAdmin)
+admin.site.register(Navigation, NavigationAdmin)
+admin.site.register(NavigationItem, NavigationItemAdmin)
\ No newline at end of file