From 114a6fb65e14f15487bc8db33cedae011fc42cac 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 --- .../migrations/0006_delete_resourceutilization.py | 18 ++++++++++++++++ pharos-dashboard/dashboard/models.py | 14 +----------- pharos-dashboard/dashboard/urls.py | 4 ++-- pharos-dashboard/dashboard/views.py | 25 +++++++++++----------- 4 files changed, 34 insertions(+), 27 deletions(-) create mode 100644 pharos-dashboard/dashboard/migrations/0006_delete_resourceutilization.py (limited to 'pharos-dashboard/dashboard') diff --git a/pharos-dashboard/dashboard/migrations/0006_delete_resourceutilization.py b/pharos-dashboard/dashboard/migrations/0006_delete_resourceutilization.py new file mode 100644 index 0000000..fb637bd --- /dev/null +++ b/pharos-dashboard/dashboard/migrations/0006_delete_resourceutilization.py @@ -0,0 +1,18 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.10 on 2016-08-16 10:42 +from __future__ import unicode_literals + +from django.db import migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ('dashboard', '0005_remove_resource_slavename'), + ] + + operations = [ + migrations.DeleteModel( + name='ResourceUtilization', + ), + ] diff --git a/pharos-dashboard/dashboard/models.py b/pharos-dashboard/dashboard/models.py index cb6b92b..02073e6 100644 --- a/pharos-dashboard/dashboard/models.py +++ b/pharos-dashboard/dashboard/models.py @@ -17,16 +17,4 @@ class Resource(models.Model): db_table = 'resource' def __str__(self): - return self.name - - -class ResourceUtilization(models.Model): - POD_STATUS = { - 'online': 1, - 'idle': 2, - 'offline': 3 - } - - id = models.AutoField(primary_key=True) - timestamp = models.DateTimeField(auto_created=True) - pod_status = models.IntegerField() + return self.name \ No newline at end of file diff --git a/pharos-dashboard/dashboard/urls.py b/pharos-dashboard/dashboard/urls.py index 2223e39..51d764c 100644 --- a/pharos-dashboard/dashboard/urls.py +++ b/pharos-dashboard/dashboard/urls.py @@ -21,8 +21,8 @@ urlpatterns = [ url(r'^ci_pods/$', CIPodsView.as_view(), name='ci_pods'), url(r'^dev_pods/$', DevelopmentPodsView.as_view(), name='dev_pods'), url(r'^jenkins_slaves/$', JenkinsSlavesView.as_view(), name='jenkins_slaves'), - url(r'^resource/all/utilization$', ResourceUtilizationView.as_view(), - name='resource_utilization'), + url(r'^resource/all/', LabOwnerView.as_view(), + name='resources'), url(r'^$', DevelopmentPodsView.as_view(), name="index"), ] diff --git a/pharos-dashboard/dashboard/views.py b/pharos-dashboard/dashboard/views.py index da31802..6af2c1a 100644 --- a/pharos-dashboard/dashboard/views.py +++ b/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