Have the sidebar be rebuilt on every request with callbacks
This makes is possible for the sidebar constructing to take
into account the current users privilidges etc.
--- a/app/soc/views/helper/responses.py Mon Nov 24 22:34:56 2008 +0000
+++ b/app/soc/views/helper/responses.py Tue Nov 25 17:18:57 2008 +0000
@@ -106,7 +106,7 @@
context['is_debug'] = system.isDebug()
context['sign_in'] = users.create_login_url(request.path)
context['sign_out'] = users.create_logout_url(request.path)
- context['sidebar_menu_items'] = sidebar.SIDEBAR
+ context['sidebar_menu_items'] = sidebar.getSidebar()
context['soc_release'] = release.RELEASE_TAG
context['gae_version'] = system.getAppVersion()
--- a/app/soc/views/sitemap/build.py Mon Nov 24 22:34:56 2008 +0000
+++ b/app/soc/views/sitemap/build.py Tue Nov 25 17:18:57 2008 +0000
@@ -36,27 +36,21 @@
from soc.views.sitemap import sitemap
-sidebar.SIDEBAR.append(user.view.getUserSidebar())
-
-#sidebar.SIDEBAR.append(presence.view.getSidebarLinks())
-#sitemap.addPages(presence.view.getDjangoURLPatterns())
-
-sidebar.SIDEBAR.append(site.view.getSidebarLinks())
-sitemap.addPages(site.view.getDjangoURLPatterns())
-
-sidebar.SIDEBAR.append(user.view.getSidebarLinks())
-sitemap.addPages(user.view.getDjangoURLPatterns())
+sidebar.addMenu(user.view.getUserSidebar)
+sidebar.addMenu(presence.view.getSidebarLinks)
+sidebar.addMenu(site.view.getSidebarLinks)
+sidebar.addMenu(user.view.getSidebarLinks)
+sidebar.addMenu(document.view.getSidebarLinks)
+sidebar.addMenu(sponsor.view.getSidebarLinks)
+sidebar.addMenu(host.view.getSidebarLinks)
+sidebar.addMenu(request.view.getSidebarLinks)
-sidebar.SIDEBAR.append(document.view.getSidebarLinks())
+sitemap.addPages(presence.view.getDjangoURLPatterns())
+sitemap.addPages(site.view.getDjangoURLPatterns())
+sitemap.addPages(user.view.getDjangoURLPatterns())
sitemap.addPages(document.view.getDjangoURLPatterns())
-
-sidebar.SIDEBAR.append(sponsor.view.getSidebarLinks())
sitemap.addPages(sponsor.view.getDjangoURLPatterns())
-
-sidebar.SIDEBAR.append(host.view.getSidebarLinks())
sitemap.addPages(host.view.getDjangoURLPatterns())
-
-sidebar.SIDEBAR.append(request.view.getSidebarLinks())
sitemap.addPages(request.view.getDjangoURLPatterns())
--- a/app/soc/views/sitemap/sidebar.py Mon Nov 24 22:34:56 2008 +0000
+++ b/app/soc/views/sitemap/sidebar.py Tue Nov 25 17:18:57 2008 +0000
@@ -25,6 +25,15 @@
SIDEBAR = []
-def addMenu(pages):
+def addMenu(callback):
global SIDEBAR
- SIDEBAR.append(pages)
+ SIDEBAR.append(callback)
+
+def getSidebar():
+ sidebar = []
+
+ for callback in SIDEBAR:
+ menu = callback()
+ sidebar.append(menu)
+
+ return sidebar