# HG changeset patch # User Sverre Rabbelier # Date 1227633537 0 # Node ID 903890857ed89b7acde88ee5379d98eb52b80249 # Parent ba8a624506e52168db7e713e33a71f9776492da4 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. diff -r ba8a624506e5 -r 903890857ed8 app/soc/views/helper/responses.py --- 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() diff -r ba8a624506e5 -r 903890857ed8 app/soc/views/sitemap/build.py --- 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()) diff -r ba8a624506e5 -r 903890857ed8 app/soc/views/sitemap/sidebar.py --- 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