diff options
author | maxbr <maxbr@mi.fu-berlin.de> | 2016-08-19 17:15:28 +0200 |
---|---|---|
committer | maxbr <maxbr@mi.fu-berlin.de> | 2016-08-19 17:15:28 +0200 |
commit | ebaa05ab2b53634a7a3e738618a031fd1518d796 (patch) | |
tree | 2df4bf769f6ed52f4b9109a96d3194aa5a95e453 /tools/pharos-dashboard/dashboard/views.py | |
parent | 54322038f766be460b676d60974886be5f04d8f3 (diff) |
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 <maxbr@mi.fu-berlin.de>
Diffstat (limited to 'tools/pharos-dashboard/dashboard/views.py')
-rw-r--r-- | tools/pharos-dashboard/dashboard/views.py | 25 |
1 files changed, 13 insertions, 12 deletions
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 |