fix fault if no controller when retrieving stats
diff --git a/planetstack/core/static/page_analytics.js b/planetstack/core/static/page_analytics.js
index 9cdd7ed..698396f 100644
--- a/planetstack/core/static/page_analytics.js
+++ b/planetstack/core/static/page_analytics.js
@@ -10,7 +10,9 @@
type : 'GET',
success: function(newData) {
console.log(newData);
- if (newData.stat_list.length > 0) {
+ if (newData.error) {
+ $(buttonSelector).text(newData.error);
+ } else if (newData.stat_list.length > 0) {
value = newData.stat_list.slice(-1)[0].value;
console.log(value);
$(buttonSelector).text(Math.round(value)).show();
diff --git a/planetstack/core/views/stats.py b/planetstack/core/views/stats.py
index 89478b8..f0cdd74 100644
--- a/planetstack/core/views/stats.py
+++ b/planetstack/core/views/stats.py
@@ -12,9 +12,7 @@
controller = Controller.objects.filter(name=controller_name)
if len(controller)==0:
- # controller was not found...
- # probably should put some kind of error response here
- return HttpResponse(json.dumps({"stat_list": []}))
+ return HttpResponse(json.dumps({"stat_list": [], "error": "not found"}))
controller=controller[0]
keystone = {'username':controller.admin_user, 'password':controller.admin_password, 'tenant_name':controller.admin_tenant, 'auth_url':controller.auth_url, 'cacert':'/etc/ssl/certs/ca-certificates.crt'}