]> git.openstreetmap.org Git - osqa.git/blob - forum/modules/ui.py
Adds the user menu to the injectable places, makes several improvements in the user...
[osqa.git] / forum / modules / ui.py
1
2
3 class Registry(list):
4     def add(self, item):
5         for i, r in enumerate(self):
6             if r.weight > item.weight:
7                 self.insert(i, item)
8                 return
9
10         self.append(item)
11
12
13 HEAD_CONTENT = 'HEAD_CONTENT'
14 HEADER_LINKS = 'HEADER_LINKS'
15 PAGE_TOP_TABS = 'PAGE_TOP_TABS'
16 FOOTER_LINKS = 'FOOTER_LINKS'
17 PROFILE_TABS = 'PROFILE_TABS'
18
19 USER_MENU = 'USER_MENU'
20
21
22 __CONTAINER = {
23     HEAD_CONTENT: Registry(),
24     HEADER_LINKS: Registry(),
25     PAGE_TOP_TABS: Registry(),
26     FOOTER_LINKS: Registry(),
27     PROFILE_TABS: Registry(),
28
29     USER_MENU: Registry(),
30 }
31
32
33 def register(registry, *ui_objects):
34     if not registry in __CONTAINER:
35         raise('unknown registry')
36
37     for ui_object in ui_objects:
38         __CONTAINER[registry].add(ui_object)
39
40 def get_registry_by_name(name):
41     name = name.upper()
42
43     if not name in __CONTAINER:
44         raise('unknown registry')
45
46     return __CONTAINER[name]
47
48
49
50 from ui_objects import *
51