add support for single-dashboard views
diff --git a/planetstack/core/plus/sites.py b/planetstack/core/plus/sites.py
index 20c2d6a..b496481 100644
--- a/planetstack/core/plus/sites.py
+++ b/planetstack/core/plus/sites.py
@@ -12,7 +12,7 @@
def get_urls(self):
"""Add our dashboard view to the admin urlconf. Deleted the default index."""
from django.conf.urls import patterns, url
- from views import DashboardWelcomeView, DashboardAjaxView, SimulatorView, DashboardSummaryAjaxView, DashboardAddOrRemoveSliverView, DashboardUserSiteView, DashboardAnalyticsAjaxView, TenantViewData,TenantCreateSlice, TenantAddOrRemoveSliverView, TenantPickSitesView, TenantDeleteSliceView,TenantUpdateSlice
+ from views import DashboardView, DashboardWelcomeView, DashboardAjaxView, SimulatorView, DashboardSummaryAjaxView, DashboardAddOrRemoveSliverView, DashboardUserSiteView, DashboardAnalyticsAjaxView, TenantViewData,TenantCreateSlice, TenantAddOrRemoveSliverView, TenantPickSitesView, TenantDeleteSliceView,TenantUpdateSlice
urls = super(AdminMixin, self).get_urls()
del urls[0]
@@ -21,6 +21,8 @@
name="index"),
url(r'^test/', self.admin_view(DashboardUserSiteView.as_view()),
name="test"),
+ url(r'^dashboard/(?P<name>\w+)/$', self.admin_view(DashboardView.as_view()),
+ name="dashboard"),
url(r'^hpcdashuserslices/', self.admin_view(DashboardUserSiteView.as_view()),
name="hpcdashuserslices"),
url(r'^hpcdashboard/', self.admin_view(DashboardAjaxView.as_view()), # DEPRECATED
diff --git a/planetstack/core/plus/views.py b/planetstack/core/plus/views.py
index 9f5d8e4..37165c0 100644
--- a/planetstack/core/plus/views.py
+++ b/planetstack/core/plus/views.py
@@ -11,6 +11,7 @@
from core.models import *
from hpc.models import ContentProvider
from operator import attrgetter
+from django import template
from django.views.decorators.csrf import csrf_exempt
from django.http import HttpResponse, HttpResponseServerError
from django.core import urlresolvers
@@ -41,6 +42,34 @@
context['cdnContentProviders'] = userDetails['cdnContentProviders']
return self.render_to_response(context=context)
+class DashboardView(TemplateView):
+ head_template = r"""{% extends "admin/dashboard/dashboard_base.html" %}
+ {% load admin_static %}
+ {% block content %}
+ """
+
+ tail_template = r"{% endblock %}"
+
+ def get(self, request, name="hpc_historical", *args, **kwargs):
+ context = self.get_context_data(**kwargs)
+
+ t = template.Template(self.head_template + open("/opt/planetstack/templates/admin/dashboard/%s.html" % name, "r").read() + self.tail_template)
+
+ userDetails = getUserSliceInfo(request.user)
+ #context['site'] = userDetails['site']
+
+ context['userSliceInfo'] = userDetails['userSliceInfo']
+ context['cdnData'] = userDetails['cdnData']
+ context['cdnContentProviders'] = userDetails['cdnContentProviders']
+
+ response_kwargs = {}
+ response_kwargs.setdefault('content_type', self.content_type)
+ return self.response_class(
+ request = request,
+ template = t,
+ context = context,
+ **response_kwargs)
+
def getUserSliceInfo(user, tableFormat = False):
userDetails = {}