From ebaa05ab2b53634a7a3e738618a031fd1518d796 Mon Sep 17 00:00:00 2001 From: maxbr Date: Fri, 19 Aug 2016 17:15:28 +0200 Subject: Use Jira Oauth for user authentication JIRA: RELENG-12 Users can use their jira accounts for the dashboard. This also allows the dasboard to open jira tickets for bookings. Signed-off-by: maxbr --- tools/pharos-dashboard/dashboard/views.py | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) (limited to 'tools/pharos-dashboard/dashboard/views.py') diff --git a/tools/pharos-dashboard/dashboard/views.py b/tools/pharos-dashboard/dashboard/views.py index da31802f..6af2c1ad 100644 --- a/tools/pharos-dashboard/dashboard/views.py +++ b/tools/pharos-dashboard/dashboard/views.py @@ -4,7 +4,6 @@ from django.views.generic import TemplateView from booking.models import Booking from dashboard.models import Resource -from jenkins import adapter as jenkins from jenkins.models import JenkinsSlave, JenkinsStatistic @@ -50,11 +49,11 @@ class DevelopmentPodsView(TemplateView): return context -class ResourceUtilizationView(TemplateView): - template_name = "dashboard/resource_utilization.html" +class LabOwnerView(TemplateView): + template_name = "dashboard/lab_owner.html" def get_context_data(self, **kwargs): - resources = Resource.objects.all() + resources = Resource.objects.filter(slave__dev_pod=True) pods = [] for resource in resources: utilization = {'idle': 0, 'online': 0, 'offline': 0} @@ -62,12 +61,14 @@ class ResourceUtilizationView(TemplateView): statistics = JenkinsStatistic.objects.filter(slave=resource.slave, timestamp__gte=timezone.now() - timedelta( days=7)) - statistics_cnt = statistics.count() - if statistics_cnt != 0: - utilization['idle'] = statistics.filter(idle=True).count() - utilization['online'] = statistics.filter(online=True).count() - utilization['offline'] = statistics.filter(offline=True).count() - pods.append((resource, utilization)) - context = super(ResourceUtilizationView, self).get_context_data(**kwargs) - context.update({'title': "Development Pods", 'pods': pods}) + + utilization['idle'] = statistics.filter(idle=True).count() + utilization['online'] = statistics.filter(online=True).count() + utilization['offline'] = statistics.filter(offline=True).count() + + bookings = Booking.objects.filter(resource=resource, end__gt=timezone.now()) + + pods.append((resource, utilization, bookings)) + context = super(LabOwnerView, self).get_context_data(**kwargs) + context.update({'title': "Overview", 'pods': pods}) return context -- cgit 1.2.3-korg