# HG changeset patch # User Sverre Rabbelier # Date 1233109645 0 # Node ID 2a0ae648382512a2ecac72e82756767b798d49db # Parent d849b47645f9d36e445cf41d8cbe56afe99c7fd3 Group dynamically generated menu items Also allow for grouping other views by setting the 'sidebar_grouping' param to a value another than 'main'. Patch by: Sverre Rabbelier diff -r d849b47645f9 -r 2a0ae6483825 app/soc/templates/soc/sidebar/menuitem.html --- a/app/soc/templates/soc/sidebar/menuitem.html Wed Jan 28 02:25:51 2009 +0000 +++ b/app/soc/templates/soc/sidebar/menuitem.html Wed Jan 28 02:27:25 2009 +0000 @@ -1,3 +1,3 @@ -
  • -{{ item.title }} -
  • \ No newline at end of file +
  • + {{ item.title }} +
  • \ No newline at end of file diff -r d849b47645f9 -r 2a0ae6483825 app/soc/templates/soc/sidebar/sidebar.html --- a/app/soc/templates/soc/sidebar/sidebar.html Wed Jan 28 02:25:51 2009 +0000 +++ b/app/soc/templates/soc/sidebar/sidebar.html Wed Jan 28 02:27:25 2009 +0000 @@ -1,5 +1,24 @@ \ No newline at end of file diff -r d849b47645f9 -r 2a0ae6483825 app/soc/templates/soc/sidebar/submenu.html --- a/app/soc/templates/soc/sidebar/submenu.html Wed Jan 28 02:25:51 2009 +0000 +++ b/app/soc/templates/soc/sidebar/submenu.html Wed Jan 28 02:27:25 2009 +0000 @@ -1,8 +1,8 @@ - \ No newline at end of file diff -r d849b47645f9 -r 2a0ae6483825 app/soc/views/helper/params.py --- a/app/soc/views/helper/params.py Wed Jan 28 02:25:51 2009 +0000 +++ b/app/soc/views/helper/params.py Wed Jan 28 02:27:25 2009 +0000 @@ -102,6 +102,7 @@ new_params['invite_redirect'] = '/request/list' new_params['sidebar'] = None + new_params['sidebar_grouping'] = 'main' new_params['sidebar_defaults'] = [ ('/%s/create', 'New %(name)s', 'create'), ('/%s/list', 'List %(name_plural)s', 'list'), diff -r d849b47645f9 -r 2a0ae6483825 app/soc/views/models/group.py --- a/app/soc/views/models/group.py Wed Jan 28 02:25:51 2009 +0000 +++ b/app/soc/views/models/group.py Wed Jan 28 02:27:25 2009 +0000 @@ -347,6 +347,7 @@ # add the items together menu['items'] = doc_items + group_items + menu['group'] = 'Clubs' # append this as a new menu menus.append(menu) diff -r d849b47645f9 -r 2a0ae6483825 app/soc/views/models/program.py --- a/app/soc/views/models/program.py Wed Jan 28 02:25:51 2009 +0000 +++ b/app/soc/views/models/program.py Wed Jan 28 02:27:25 2009 +0000 @@ -140,6 +140,7 @@ menu['heading'] = entity.short_name items = document_view.view.getMenusForScope(entity, params) menu['items'] = sidebar.getSidebarMenu(id, user, items, params=doc_params) + menu['group'] = 'Programs' menus.append(menu) return menus diff -r d849b47645f9 -r 2a0ae6483825 app/soc/views/sitemap/sidebar.py --- a/app/soc/views/sitemap/sidebar.py Wed Jan 28 02:25:51 2009 +0000 +++ b/app/soc/views/sitemap/sidebar.py Wed Jan 28 02:27:25 2009 +0000 @@ -22,6 +22,8 @@ ] +import operator + from soc.views import out_of_band from soc.views.helper import access @@ -56,7 +58,7 @@ for menu in (menus if menus else []): sidebar.append(menu) - return sidebar + return sorted(sidebar, key=lambda x: x.get('group')) def getSidebarItems(params): @@ -175,6 +177,7 @@ menu['heading'] = params['sidebar_heading'] menu['items'] = submenus + menu['group'] = params['sidebar_grouping'] menus = [menu]