aboutsummaryrefslogtreecommitdiffstats
path: root/lib/toaster/toastergui/widgets.py
diff options
context:
space:
mode:
Diffstat (limited to 'lib/toaster/toastergui/widgets.py')
-rw-r--r--lib/toaster/toastergui/widgets.py50
1 files changed, 27 insertions, 23 deletions
diff --git a/lib/toaster/toastergui/widgets.py b/lib/toaster/toastergui/widgets.py
index a1792d997..b32abf40b 100644
--- a/lib/toaster/toastergui/widgets.py
+++ b/lib/toaster/toastergui/widgets.py
@@ -1,25 +1,13 @@
#
-# ex:ts=4:sw=4:sts=4:et
-# -*- tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*-
-#
# BitBake Toaster Implementation
#
# Copyright (C) 2015 Intel Corporation
#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License version 2 as
-# published by the Free Software Foundation.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
+# SPDX-License-Identifier: GPL-2.0-only
#
-# You should have received a copy of the GNU General Public License along
-# with this program; if not, write to the Free Software Foundation, Inc.,
-# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
from django.views.generic import View, TemplateView
+from django.utils.decorators import method_decorator
from django.views.decorators.cache import cache_control
from django.shortcuts import HttpResponse
from django.core.cache import cache
@@ -35,7 +23,7 @@ from django.utils import timezone
from toastergui.templatetags.projecttags import sectohms, get_tasks
from toastergui.templatetags.projecttags import json as template_json
from django.http import JsonResponse
-from django.core.urlresolvers import reverse
+from django.urls import reverse
import types
import json
@@ -44,6 +32,7 @@ import re
import os
from toastergui.tablefilter import TableFilterMap
+from toastermain.logs import log_view_mixin
try:
from urllib import unquote_plus
@@ -76,8 +65,8 @@ class ToasterTable(TemplateView):
self.default_orderby = ""
# prevent HTTP caching of table data
- @cache_control(must_revalidate=True,
- max_age=0, no_store=True, no_cache=True)
+ @method_decorator(cache_control(must_revalidate=True,
+ max_age=0, no_store=True, no_cache=True))
def dispatch(self, *args, **kwargs):
return super(ToasterTable, self).dispatch(*args, **kwargs)
@@ -89,9 +78,14 @@ class ToasterTable(TemplateView):
# global variables
context['project_enable'] = ('1' == os.environ.get('TOASTER_BUILDSERVER'))
+ try:
+ context['project_specific'] = ('1' == os.environ.get('TOASTER_PROJECTSPECIFIC'))
+ except:
+ context['project_specific'] = ''
return context
+ @log_view_mixin
def get(self, request, *args, **kwargs):
if request.GET.get('format', None) == 'json':
@@ -313,6 +307,7 @@ class ToasterTable(TemplateView):
self.setup_columns(**kwargs)
+ self.apply_orderby('pk')
if search:
self.apply_search(search)
if filters:
@@ -422,6 +417,7 @@ class ToasterTypeAhead(View):
def __init__(self, *args, **kwargs):
super(ToasterTypeAhead, self).__init__()
+ @log_view_mixin
def get(self, request, *args, **kwargs):
def response(data):
return HttpResponse(json.dumps(data,
@@ -477,6 +473,7 @@ class MostRecentBuildsView(View):
return False
+ @log_view_mixin
def get(self, request, *args, **kwargs):
"""
Returns a list of builds in JSON format.
@@ -511,13 +508,20 @@ class MostRecentBuildsView(View):
buildrequest_id = build_obj.buildrequest.pk
build['buildrequest_id'] = buildrequest_id
- build['recipes_parsed_percentage'] = \
- int((build_obj.recipes_parsed /
- build_obj.recipes_to_parse) * 100)
+ if build_obj.recipes_to_parse > 0:
+ build['recipes_parsed_percentage'] = \
+ int((build_obj.recipes_parsed /
+ build_obj.recipes_to_parse) * 100)
+ else:
+ build['recipes_parsed_percentage'] = 0
+ if build_obj.repos_to_clone > 0:
+ build['repos_cloned_percentage'] = \
+ int((build_obj.repos_cloned /
+ build_obj.repos_to_clone) * 100)
+ else:
+ build['repos_cloned_percentage'] = 0
- build['repos_cloned_percentage'] = \
- int((build_obj.repos_cloned /
- build_obj.repos_to_clone) * 100)
+ build['progress_item'] = build_obj.progress_item
tasks_complete_percentage = 0
if build_obj.outcome in (Build.SUCCEEDED, Build.FAILED):