Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 72 lines (55 sloc) 1.824 kb
253adda @digi604 initial menu refactor
digi604 authored
1
589de2c @digi604 some start of the menu discover infrastructure
digi604 authored
2
3 class Menu(object):
4 nodes = []
5
6 def get_nodes(self, request):
7 raise NotImplementedError
8
5c9aa1f @digi604 imports now working, show_menu displays nothing yet
digi604 authored
9 def get_node_by_id(self, id):
10 for node in self.nodes:
11 if node.id == id:
12 return node
13
589de2c @digi604 some start of the menu discover infrastructure
digi604 authored
14 class Modifier(object):
6e71206 @digi604 show menu working. marking of nodes working. modifiers working. cutlevel...
digi604 authored
15 pre_cut = True
16 post_cut = False
589de2c @digi604 some start of the menu discover infrastructure
digi604 authored
17
6e71206 @digi604 show menu working. marking of nodes working. modifiers working. cutlevel...
digi604 authored
18 def set_nodes(self, nodes):
19 self.nodes = nodes
20
21 def modify(self, request, nodes, namespace, post_cut):
22 pass
23
24 def modify_all(self, request, nodes, namespace, post_cut):
25 pass
589de2c @digi604 some start of the menu discover infrastructure
digi604 authored
26
6e71206 @digi604 show menu working. marking of nodes working. modifiers working. cutlevel...
digi604 authored
27 def remove_node(self, node):
28 self.nodes.remove(node)
29 if node.parent:
30 node.parent.children.remove(node)
589de2c @digi604 some start of the menu discover infrastructure
digi604 authored
31
253adda @digi604 initial menu refactor
digi604 authored
32 class NavigationNode(object):
33 title = None
34 url = None
a36165f @digi604 some other menu refactoring... building up the api
digi604 authored
35 auth_required = False
36 required_group_id = None
253adda @digi604 initial menu refactor
digi604 authored
37 attr = {}
38 namespace = None
39 id = None
40 softroot = False
a36165f @digi604 some other menu refactoring... building up the api
digi604 authored
41 parent_id = None
42 parent_namespace = None
43 parent = None # do not touch
6e71206 @digi604 show menu working. marking of nodes working. modifiers working. cutlevel...
digi604 authored
44
45 selected = False
a36165f @digi604 some other menu refactoring... building up the api
digi604 authored
46
47 def __init__(self, title, url, namespace, id, parent_id=None, parent_namespace=None, attr=None, softroot=False, auth_required=False, required_group_id=None):
6e71206 @digi604 show menu working. marking of nodes working. modifiers working. cutlevel...
digi604 authored
48 self.children = [] # do not touch
253adda @digi604 initial menu refactor
digi604 authored
49 self.title = title
50 self.url = url
51 self.id = id
52 self.softroot = softroot
53 self.namespace = namespace
a36165f @digi604 some other menu refactoring... building up the api
digi604 authored
54 self.parent_id = parent_id
55 self.parent_namespace = parent_namespace
56 self.auth_required = auth_required
57 self.required_group_id = required_group_id
253adda @digi604 initial menu refactor
digi604 authored
58 if attr:
59 self.attr = attr
6e71206 @digi604 show menu working. marking of nodes working. modifiers working. cutlevel...
digi604 authored
60
61 def __repr__(self):
62 return "<Navigation Node: %s>" % self.title
253adda @digi604 initial menu refactor
digi604 authored
63
64 def get_menu_title(self):
65 return self.title
66
67 def get_absolute_url(self):
68 return self.url
69
70 def get_attribute(self, name):
71 return self.attr[name]
72
Something went wrong with that request. Please try again.