search for xoslib dashboards
authorScott Baker <smbaker@gmail.com>
Sun, 13 Jul 2014 23:48:46 +0000 (16:48 -0700)
committerScott Baker <smbaker@gmail.com>
Sun, 13 Jul 2014 23:48:46 +0000 (16:48 -0700)
planetstack/core/dashboard/views/home.py

index 6cb25a0..e6f77fd 100644 (file)
@@ -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 = '<div id="tabs-5"></div>' + 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 = '<div id="tabs-5"></div>' + template
+        return template
 
     def embedDashboard(self, url):
         if url.startswith("template:"):