equal
deleted
inserted
replaced
28 |
28 |
29 SIDEBAR = [] |
29 SIDEBAR = [] |
30 |
30 |
31 |
31 |
32 def addMenu(callback): |
32 def addMenu(callback): |
|
33 """Adds a callback to the menu builder. |
|
34 |
|
35 The callback should return a list of menu's when called. |
|
36 """ |
|
37 |
33 global SIDEBAR |
38 global SIDEBAR |
34 SIDEBAR.append(callback) |
39 SIDEBAR.append(callback) |
35 |
40 |
36 def getSidebar(request): |
41 def getSidebar(request): |
|
42 """Constructs a sidebar for the specified request |
|
43 """ |
|
44 |
37 sidebar = [] |
45 sidebar = [] |
38 |
46 |
39 for callback in SIDEBAR: |
47 for callback in SIDEBAR: |
40 menu = callback(request) |
48 menus = callback(request) |
41 |
49 |
42 if menu: |
50 for menu in (menus if menus else []): |
43 # only if there is a menu we should append it |
|
44 sidebar.append(menu) |
51 sidebar.append(menu) |
45 |
52 |
46 return sidebar |
53 return sidebar |
47 |
54 |
48 |
55 |
127 pass |
134 pass |
128 |
135 |
129 if not items: |
136 if not items: |
130 return |
137 return |
131 |
138 |
132 res = {} |
139 menu = {} |
133 |
140 |
134 if 'sidebar_heading' not in params: |
141 if 'sidebar_heading' not in params: |
135 params['sidebar_heading'] = params['name'] |
142 params['sidebar_heading'] = params['name'] |
136 |
143 |
137 res['heading'] = params['sidebar_heading'] |
144 menu['heading'] = params['sidebar_heading'] |
138 res['items'] = items |
145 menu['items'] = items |
139 |
146 |
140 return res |
147 menus = [menu] |
|
148 |
|
149 return menus |