diff options
Diffstat (limited to 'tools/pharos-dashboard/src/dashboard')
4 files changed, 50 insertions, 6 deletions
diff --git a/tools/pharos-dashboard/src/dashboard/admin.py b/tools/pharos-dashboard/src/dashboard/admin.py index 56ac1693..0bfdef8f 100644 --- a/tools/pharos-dashboard/src/dashboard/admin.py +++ b/tools/pharos-dashboard/src/dashboard/admin.py @@ -12,6 +12,9 @@ from django.contrib import admin from dashboard.models import * +admin.site.site_header = "Pharos Dashboard Administration" +admin.site.site_title = "Pharos Dashboard" + admin.site.register(Resource) admin.site.register(Server) admin.site.register(ResourceStatus) diff --git a/tools/pharos-dashboard/src/dashboard/migrations/0002_auto_20170505_0815.py b/tools/pharos-dashboard/src/dashboard/migrations/0002_auto_20170505_0815.py new file mode 100644 index 00000000..4285b887 --- /dev/null +++ b/tools/pharos-dashboard/src/dashboard/migrations/0002_auto_20170505_0815.py @@ -0,0 +1,42 @@ +############################################################################## +# Copyright (c) 2016 Max Breitenfeldt and others. +# +# All rights reserved. This program and the accompanying materials +# are made available under the terms of the Apache License, Version 2.0 +# which accompanies this distribution, and is available at +# http://www.apache.org/licenses/LICENSE-2.0 +############################################################################## + + +# -*- coding: utf-8 -*- +# Generated by Django 1.10 on 2017-05-05 08:15 +from __future__ import unicode_literals + +from django.conf import settings +from django.db import migrations, models +import django.db.models.deletion + + +class Migration(migrations.Migration): + + dependencies = [ + ('dashboard', '0001_initial'), + ] + + operations = [ + migrations.AddField( + model_name='resource', + name='dev_pod', + field=models.BooleanField(default=False), + ), + migrations.AlterField( + model_name='resource', + name='owner', + field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='user_lab_owner', to=settings.AUTH_USER_MODEL), + ), + migrations.AlterField( + model_name='resource', + name='slave', + field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.DO_NOTHING, to='jenkins.JenkinsSlave'), + ), + ] diff --git a/tools/pharos-dashboard/src/dashboard/models.py b/tools/pharos-dashboard/src/dashboard/models.py index 4f3ac95c..3de7db3d 100644 --- a/tools/pharos-dashboard/src/dashboard/models.py +++ b/tools/pharos-dashboard/src/dashboard/models.py @@ -22,9 +22,10 @@ class Resource(models.Model): name = models.CharField(max_length=100, unique=True) description = models.CharField(max_length=300, blank=True, null=True) url = models.CharField(max_length=100, blank=True, null=True) - owner = models.ForeignKey(User, related_name='user_lab_owner', null=True) + owner = models.ForeignKey(User, related_name='user_lab_owner', null=True, blank=True) vpn_users = models.ManyToManyField(User, related_name='user_vpn_users', blank=True) - slave = models.ForeignKey(JenkinsSlave, on_delete=models.DO_NOTHING, null=True) + slave = models.ForeignKey(JenkinsSlave, on_delete=models.DO_NOTHING, null=True, blank=True) + dev_pod = models.BooleanField(default=False) def get_booking_utilization(self, weeks): """ diff --git a/tools/pharos-dashboard/src/dashboard/views.py b/tools/pharos-dashboard/src/dashboard/views.py index 1848844b..62a9f830 100644 --- a/tools/pharos-dashboard/src/dashboard/views.py +++ b/tools/pharos-dashboard/src/dashboard/views.py @@ -45,7 +45,7 @@ class DevelopmentPodsView(TemplateView): template_name = "dashboard/dev_pods.html" def get_context_data(self, **kwargs): - resources = Resource.objects.filter(slave__dev_pod=True, slave__active=True) + resources = Resource.objects.filter(dev_pod=True) bookings = Booking.objects.filter(start__lte=timezone.now()) bookings = bookings.filter(end__gt=timezone.now()) @@ -76,11 +76,9 @@ class ResourceView(TemplateView): def get_context_data(self, **kwargs): resource = get_object_or_404(Resource, id=self.kwargs['resource_id']) - utilization = resource.slave.get_utilization(timedelta(days=7)) bookings = Booking.objects.filter(resource=resource, end__gt=timezone.now()) context = super(ResourceView, self).get_context_data(**kwargs) - context.update({'title': str(resource), 'resource': resource, 'utilization': utilization, - 'bookings': bookings}) + context.update({'title': str(resource), 'resource': resource, 'bookings': bookings}) return context |