From 186ae614af480126b0cdc59981da6d09c7c0d532 Mon Sep 17 00:00:00 2001 From: Scott Baker Date: Mon, 19 May 2014 10:42:51 -0700 Subject: [PATCH] add support for single-dashboard views --- planetstack/core/plus/sites.py | 4 +++- planetstack/core/plus/views.py | 29 +++++++++++++++++++++++++++++ 2 files changed, 32 insertions(+), 1 deletion(-) 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 @@ class AdminMixin(object): 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 @@ class AdminMixin(object): name="index"), url(r'^test/', self.admin_view(DashboardUserSiteView.as_view()), name="test"), + url(r'^dashboard/(?P\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 syndicate.models import * 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 @@ class DashboardWelcomeView(TemplateView): 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 = {} -- 2.43.0