From bbe7c82967eb726bc61d4ac02ecc7afd988c6a13 Mon Sep 17 00:00:00 2001 From: Scott Baker Date: Sun, 13 Jul 2014 16:48:46 -0700 Subject: [PATCH] search for xoslib dashboards --- planetstack/core/dashboard/views/home.py | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/planetstack/core/dashboard/views/home.py b/planetstack/core/dashboard/views/home.py index 6cb25a0..e6f77fd 100644 --- a/planetstack/core/dashboard/views/home.py +++ b/planetstack/core/dashboard/views/home.py @@ -26,14 +26,21 @@ class DashboardDynamicView(TemplateView): return self.singleDashboardView(request, name, context) def readTemplate(self, fn): - try: - template= open("/opt/planetstack/templates/admin/dashboard/%s.html" % fn, "r").read() - if (fn=="tenant"): - # fix for tenant view - it writes html to a div called tabs-5 - template = '
' + template - return template - except: - return "failed to open %s" % fn + TEMPLATE_DIRS = ["/opt/planetstack/templates/admin/dashboard/", + "/opt/planetstack/core/xoslib/dashboards/"] + + for template_dir in TEMPLATE_DIRS: + pathname = os.path.join(template_dir, fn) + ".html" + if os.path.exists(pathname): + break + else: + return "failed to find %s in %s" % (fn, TEMPLATE_DIRS) + + template= open(pathname, "r").read() + if (fn=="tenant"): + # fix for tenant view - it writes html to a div called tabs-5 + template = '
' + template + return template def embedDashboard(self, url): if url.startswith("template:"): -- 2.43.0