Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 60 lines (46 sloc) 1.491 kb
1b16cd4 @digi604 monster commit for menu refactor
digi604 authored
1 from django.core.exceptions import ValidationError
253adda @digi604 initial menu refactor
digi604 authored
2
589de2c @digi604 some start of the menu discover infrastructure
digi604 authored
3
4 class Menu(object):
bda49b2 @digi604 menu_levels working. nav-extenders correctly hiding if not assigned
digi604 authored
5 namespace = None
1b16cd4 @digi604 monster commit for menu refactor
digi604 authored
6
7 def __init__(self):
bda49b2 @digi604 menu_levels working. nav-extenders correctly hiding if not assigned
digi604 authored
8 if not self.namespace:
9 self.namespace = self.__class__.__name__
589de2c @digi604 some start of the menu discover infrastructure
digi604 authored
10
11 def get_nodes(self, request):
aeccf5b @digi604 sampleapp refactor for new menu structure
digi604 authored
12 """
13 should return a list of NavigationNode instances
14 """
589de2c @digi604 some start of the menu discover infrastructure
digi604 authored
15 raise NotImplementedError
16
17 class Modifier(object):
6e71206 @digi604 show menu working. marking of nodes working. modifiers working. cutle…
digi604 authored
18
03a78d9 @digi604 menu test cases added
digi604 authored
19 def modify(self, request, nodes, namespace, id, post_cut):
6e71206 @digi604 show menu working. marking of nodes working. modifiers working. cutle…
digi604 authored
20 pass
21
253adda @digi604 initial menu refactor
digi604 authored
22 class NavigationNode(object):
23 title = None
24 url = None
25 attr = {}
26 namespace = None
27 id = None
a36165f @digi604 some other menu refactoring... building up the api
digi604 authored
28 parent_id = None
29 parent_namespace = None
30 parent = None # do not touch
31
38225bb @digi604 testsuite working again
digi604 authored
32 def __init__(self, title, url, id, parent_id=None, parent_namespace=None, attr=None):
6e71206 @digi604 show menu working. marking of nodes working. modifiers working. cutle…
digi604 authored
33 self.children = [] # do not touch
253adda @digi604 initial menu refactor
digi604 authored
34 self.title = title
35 self.url = url
36 self.id = id
a36165f @digi604 some other menu refactoring... building up the api
digi604 authored
37 self.parent_id = parent_id
38 self.parent_namespace = parent_namespace
253adda @digi604 initial menu refactor
digi604 authored
39 if attr:
40 self.attr = attr
6e71206 @digi604 show menu working. marking of nodes working. modifiers working. cutle…
digi604 authored
41
42 def __repr__(self):
1b16cd4 @digi604 monster commit for menu refactor
digi604 authored
43 return "<Navigation Node: %s>" % str(unicode(self.title))
253adda @digi604 initial menu refactor
digi604 authored
44
45 def get_menu_title(self):
46 return self.title
47
48 def get_absolute_url(self):
49 return self.url
50
51 def get_attribute(self, name):
52 return self.attr[name]
65331d8 @digi604 softroots working
digi604 authored
53
54 def get_descendants(self):
55 nodes = []
56 for node in self.children:
57 nodes.append(node)
58 nodes += node.get_descendants()
59 return nodes
253adda @digi604 initial menu refactor
digi604 authored
60
Something went wrong with that request. Please try again.