Moved all navigation-related code to contrib/navigation. Refactored navigation to...
[philo.git] / contrib / navigation / admin.py
1 from django.contrib import admin
2 from philo.admin import TreeEntityAdmin, COLLAPSE_CLASSES, NodeAdmin
3 from philo.contrib.navigation.models import Navigation
4
5
6 NAVIGATION_RAW_ID_FIELDS = ('hosting_node', 'parent', 'target_node')
7
8
9 class NavigationInline(admin.StackedInline):
10         fieldsets = (
11                 (None, {
12                         'fields': ('text',)
13                 }),
14                 ('Target', {
15                         'fields': ('target_node', 'url_or_subpath',)
16                 }),
17                 ('Advanced', {
18                         'fields': ('reversing_parameters', 'order', 'depth'),
19                         'classes': COLLAPSE_CLASSES
20                 }),
21                 ('Expert', {
22                         'fields': ('hosting_node', 'parent'),
23                         'classes': COLLAPSE_CLASSES
24                 })
25         )
26         raw_id_fields = NAVIGATION_RAW_ID_FIELDS
27         model = Navigation
28         extra = 1
29         sortable_field_name = 'order'
30
31
32 class NavigationNavigationInline(NavigationInline):
33         verbose_name = "child"
34         verbose_name_plural = "children"
35
36
37 class NodeNavigationInline(NavigationInline):
38         verbose_name_plural = 'navigation'
39
40
41 class NavigationAdmin(TreeEntityAdmin):
42         fieldsets = (
43                 (None, {
44                         'fields': ('text', 'hosting_node',)
45                 }),
46                 ('Target', {
47                         'fields': ('target_node', 'url_or_subpath',)
48                 }),
49                 ('Advanced', {
50                         'fields': ('reversing_parameters', 'depth'),
51                         'classes': COLLAPSE_CLASSES
52                 }),
53                 ('Expert', {
54                         'fields': ('parent', 'order'),
55                         'classes': COLLAPSE_CLASSES
56                 })
57         )
58         raw_id_fields = NAVIGATION_RAW_ID_FIELDS
59         inlines = [NavigationNavigationInline] + TreeEntityAdmin.inlines
60
61
62 NodeAdmin.inlines = [NodeNavigationInline] + NodeAdmin.inlines
63
64
65 admin.site.register(Navigation, NavigationAdmin)