X-Git-Url: http://git.ithinksw.org/philo.git/blobdiff_plain/4d7f6c42629cb85f001306195c6098b4abec642a..d807884e8aa5b94a79e5f130fd2ce711e287eb3a:/contrib/shipherd/admin.py?ds=inline diff --git a/contrib/shipherd/admin.py b/contrib/shipherd/admin.py index a54d0f1..fb6cffe 100644 --- a/contrib/shipherd/admin.py +++ b/contrib/shipherd/admin.py @@ -1,61 +1,89 @@ from django.contrib import admin -from philo.admin import TreeEntityAdmin, COLLAPSE_CLASSES, NodeAdmin +from philo.admin import TreeEntityAdmin, COLLAPSE_CLASSES, NodeAdmin, EntityAdmin from philo.models import Node -from philo.contrib.shipherd.models import Navigation +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 NodeHostedNavigationInline(NavigationInline): - verbose_name_plural = 'hosted navigation' - fk_name = 'hosting_node' +class NodeNavigationInline(admin.TabularInline): + model = Navigation + extra = 1 -class NodeTargetingNavigationInline(NavigationInline): - verbose_name_plural = 'targeting navigation' - fk_name = 'target_node' +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', { @@ -64,12 +92,15 @@ class NavigationAdmin(TreeEntityAdmin): }) ) raw_id_fields = NAVIGATION_RAW_ID_FIELDS - inlines = [NavigationNavigationInline] + TreeEntityAdmin.inlines + inlines = [NavigationItemChildInline] + TreeEntityAdmin.inlines -NodeAdmin.inlines = [NodeHostedNavigationInline, NodeTargetingNavigationInline] + NodeAdmin.inlines +class NavigationAdmin(EntityAdmin): + inlines = [NavigationNavigationItemInline] + raw_id_fields = ['node'] admin.site.unregister(Node) admin.site.register(Node, NodeAdmin) -admin.site.register(Navigation, NavigationAdmin) \ No newline at end of file +admin.site.register(Navigation, NavigationAdmin) +admin.site.register(NavigationItem, NavigationItemAdmin) \ No newline at end of file