Merge "Corrected dash.can_access call to take context"
This commit is contained in:
commit
9041432629
|
@ -82,7 +82,7 @@ def horizon_main_nav(context):
|
||||||
current_dashboard = context['request'].horizon.get('dashboard', None)
|
current_dashboard = context['request'].horizon.get('dashboard', None)
|
||||||
dashboards = []
|
dashboards = []
|
||||||
for dash in Horizon.get_dashboards():
|
for dash in Horizon.get_dashboards():
|
||||||
if dash.can_access(context['request']):
|
if dash.can_access(context):
|
||||||
if callable(dash.nav) and dash.nav(context):
|
if callable(dash.nav) and dash.nav(context):
|
||||||
dashboards.append(dash)
|
dashboards.append(dash)
|
||||||
elif dash.nav:
|
elif dash.nav:
|
||||||
|
|
|
@ -491,6 +491,11 @@ class RbacHorizonTests(test.TestCase):
|
||||||
base.Horizon = base.HorizonSite()
|
base.Horizon = base.HorizonSite()
|
||||||
# Reload the convenience references to Horizon stored in __init__
|
# Reload the convenience references to Horizon stored in __init__
|
||||||
reload(import_module("horizon"))
|
reload(import_module("horizon"))
|
||||||
|
|
||||||
|
# Reset Cats and Dogs default_panel to default values
|
||||||
|
Cats.default_panel = 'kittens'
|
||||||
|
Dogs.default_panel = 'puppies'
|
||||||
|
|
||||||
# Re-register our original dashboards and panels.
|
# Re-register our original dashboards and panels.
|
||||||
# This is necessary because autodiscovery only works on the first
|
# This is necessary because autodiscovery only works on the first
|
||||||
# import, and calling reload introduces innumerable additional
|
# import, and calling reload introduces innumerable additional
|
||||||
|
|
|
@ -24,6 +24,10 @@ from django.template import Template # noqa
|
||||||
from django.utils.text import normalize_newlines # noqa
|
from django.utils.text import normalize_newlines # noqa
|
||||||
|
|
||||||
from horizon.test import helpers as test
|
from horizon.test import helpers as test
|
||||||
|
from horizon.test.test_dashboards.cats.dashboard import Cats # noqa
|
||||||
|
from horizon.test.test_dashboards.cats.kittens.panel import Kittens # noqa
|
||||||
|
from horizon.test.test_dashboards.dogs.dashboard import Dogs # noqa
|
||||||
|
from horizon.test.test_dashboards.dogs.puppies.panel import Puppies # noqa
|
||||||
|
|
||||||
|
|
||||||
def single_line(text):
|
def single_line(text):
|
||||||
|
@ -106,3 +110,21 @@ class TemplateTagTests(test.TestCase):
|
||||||
template_text=text,
|
template_text=text,
|
||||||
context={'test': ctx_string})
|
context={'test': ctx_string})
|
||||||
self.assertEqual(expected, rendered_str)
|
self.assertEqual(expected, rendered_str)
|
||||||
|
|
||||||
|
def test_horizon_main_nav(self):
|
||||||
|
text = "{% horizon_main_nav %}"
|
||||||
|
expected = """
|
||||||
|
<div class='clearfix'>
|
||||||
|
<ul class=\"nav nav-tabs\">
|
||||||
|
<li>
|
||||||
|
<a href=\"/cats/\" tabindex='1'>Cats</a>
|
||||||
|
</li>
|
||||||
|
<li>
|
||||||
|
<a href=\"/dogs/\" tabindex='1'>Dogs</a>
|
||||||
|
</li>
|
||||||
|
</ul></div>"""
|
||||||
|
|
||||||
|
rendered_str = self.render_template(tag_require='horizon',
|
||||||
|
template_text=text,
|
||||||
|
context={'request': self.request})
|
||||||
|
self.assertEqual(single_line(rendered_str), single_line(expected))
|
||||||
|
|
Loading…
Reference in New Issue