diff options
author | Gabriel Hurley <gabriel@strikeawe.com> | 2012-03-26 18:08:48 -0700 |
---|---|---|
committer | Gabriel Hurley <gabriel@strikeawe.com> | 2012-03-26 18:22:07 -0700 |
commit | ac712468029ea2981e912da36afd74a9a5de67bf (patch) | |
tree | 88bf8cbba2edda5b115042fe776c5a8ae523e7d8 /horizon/templatetags/horizon.py | |
parent | a5d5b4f288b509342bbec57adff8ed94a829354e (diff) | |
download | horizon-ac712468029ea2981e912da36afd74a9a5de67bf.tar.gz |
Adds PanelGroup class and site customization hook.
* Adds a PanelGroup class and slightly reworks the way panel
ordering is handled to fix bug 963550.
* Adds the option to load a python module containing
site customizations after the site is fully initialized,
but before the URLConf is dynamically constructed.
Fixes bug 965839.
Change-Id: Idc5358f2db6751494bcdfc382ec3bb6af65199b9
Diffstat (limited to 'horizon/templatetags/horizon.py')
-rw-r--r-- | horizon/templatetags/horizon.py | 26 |
1 files changed, 12 insertions, 14 deletions
diff --git a/horizon/templatetags/horizon.py b/horizon/templatetags/horizon.py index dae7153dc..68df33eee 100644 --- a/horizon/templatetags/horizon.py +++ b/horizon/templatetags/horizon.py @@ -16,9 +16,8 @@ from __future__ import absolute_import -import copy - from django import template +from django.utils.datastructures import SortedDict from horizon.base import Horizon @@ -78,21 +77,20 @@ def horizon_dashboard_nav(context): if 'request' not in context: return {} dashboard = context['request'].horizon['dashboard'] - if isinstance(dashboard.panels, dict): - panels = copy.copy(dashboard.get_panels()) - else: - panels = {dashboard.name: dashboard.get_panels()} + panel_groups = dashboard.get_panel_groups() + non_empty_groups = [] - for heading, items in panels.iteritems(): - temp_panels = [] - for panel in items: + for group in panel_groups.values(): + allowed_panels = [] + for panel in group: if callable(panel.nav) and panel.nav(context): - temp_panels.append(panel) + allowed_panels.append(panel) elif not callable(panel.nav) and panel.nav: - temp_panels.append(panel) - panels[heading] = temp_panels - non_empty_panels = dict([(k, v) for k, v in panels.items() if len(v) > 0]) - return {'components': non_empty_panels, + allowed_panels.append(panel) + if allowed_panels: + non_empty_groups.append((group.name, allowed_panels)) + + return {'components': SortedDict(non_empty_groups), 'user': context['request'].user, 'current': context['request'].horizon['panel'].slug, 'request': context['request']} |