From: Scott Baker Date: Sun, 13 Jul 2014 23:48:46 +0000 (-0700) Subject: search for xoslib dashboards X-Git-Url: http://git.onelab.eu/?a=commitdiff_plain;h=bbe7c82967eb726bc61d4ac02ecc7afd988c6a13;p=plstackapi.git search for xoslib dashboards --- 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:"):