]> git.openstreetmap.org Git - osqa.git/blobdiff - forum/modules/ui.py
resolves OSQA-729, encode OpenID query dict using the django smart unicode utility...
[osqa.git] / forum / modules / ui.py
index 5cfcac42b5d2347daa85cc552333a264c26c2785..26941104d8a35d61198dc202b4dfc0de5ed58cf4 100644 (file)
@@ -1,37 +1,51 @@
 
 
 class Registry(list):
-    def add(self, register):
+    def add(self, item):
         for i, r in enumerate(self):
-            if r.weight > register.weight:
-                self.insert(i, register)
+            if r.weight > item.weight:
+                self.insert(i, item)
                 return
 
-        self.append(register)
+        self.append(item)
 
-"""Links next in the very top of the page"""
-HEADER_LINKS = 'HEADER_LINKS'
+    def find_by_name(self, name):
+        for i in self:
+            if i.name and (i.name == name):
+                return i
+
+    def remove_by_name(self, name):
+        for i, r in enumerate(self):
+            if r.name and (r.name == name):
+                return self.pop(i)
 
-"""The tabs next to the top of the page"""
+
+HEAD_CONTENT = 'HEAD_CONTENT'
+HEADER_LINKS = 'HEADER_LINKS'
 PAGE_TOP_TABS = 'PAGE_TOP_TABS'
+FOOTER_LINKS = 'FOOTER_LINKS'
+PROFILE_TABS = 'PROFILE_TABS'
+
+USER_MENU = 'USER_MENU'
 
 
 __CONTAINER = {
+    HEAD_CONTENT: Registry(),
     HEADER_LINKS: Registry(),
-    PAGE_TOP_TABS: Registry()
+    PAGE_TOP_TABS: Registry(),
+    FOOTER_LINKS: Registry(),
+    PROFILE_TABS: Registry(),
+
+    USER_MENU: Registry(),
 }
 
 
-def register(registry, ui_object):
+def register(registry, *ui_objects):
     if not registry in __CONTAINER:
         raise('unknown registry')
 
-    __CONTAINER[registry].add(ui_object)
-
-def register_multi(registry, *ui_objects):
     for ui_object in ui_objects:
-        register(registry, ui_object)
-
+        __CONTAINER[registry].add(ui_object)
 
 def get_registry_by_name(name):
     name = name.upper()