From 5982b5df9288a5773c7314234e2e0432f85678f2 Mon Sep 17 00:00:00 2001 From: Alexandru DAMIAN Date: Tue, 18 Aug 2015 17:29:00 +0100 Subject: toastergui: fix projectbuilds page This patch fixes the redirection projectbuilds page and the template layout in the projectbuilds page. * The _build_list_helper now returns an empty RedirectException that is properly customized by the caller and re-raised to achieve redirection to the original page (poor man's overloading) * The template for ProjectBuilds is updated as to properly display Build objects instead of BuildRequest objects. [YOCTO #7995] Signed-off-by: Alexandru DAMIAN Signed-off-by: Michael Wood Signed-off-by: Richard Purdie --- .../toastergui/templates/projectbuilds.html | 42 +++------------------- lib/toaster/toastergui/views.py | 24 +++++++++---- 2 files changed, 21 insertions(+), 45 deletions(-) diff --git a/lib/toaster/toastergui/templates/projectbuilds.html b/lib/toaster/toastergui/templates/projectbuilds.html index 646755b18..f1db2f150 100644 --- a/lib/toaster/toastergui/templates/projectbuilds.html +++ b/lib/toaster/toastergui/templates/projectbuilds.html @@ -16,8 +16,8 @@ @@ -28,7 +28,7 @@ {%elif request.GET.filter and objects.paginator.count == 0 or request.GET.search and objects.paginator.count == 0 %} No builds found {%else%} - All builds + Project builds {%endif%} @@ -58,7 +58,7 @@ {% include "basetable_top.html" %} - {% for br in objects %}{% if br.build %} {% with build=br.build %} {# if we have a build, just display it #} + {% for build in objects %} {# if we have a build, just display it #} {%if build.outcome == build.SUCCEEDED%}{%elif build.outcome == build.FAILED%}{%else%}{%endif%} {% if build.project %} @@ -96,40 +96,6 @@ {% endif %} - - {%endwith%} - {% else %} {# we don't have a build for this build request, mask the data with build request data #} - - - - - {% if br.state == br.REQ_FAILED %}{%else%}FIXME_build_request_state{%endif%} - - 1%}title="Targets: {%for target in br.brtarget_set.all%}{{target.target}} {%endfor%}"{%endif%}>{{br.brtarget_set.all.0.target}} {%if br.brtarget_set.all.count > 1%}(+ {{br.brtarget_set.all.count|add:"-1"}}){%endif%} - - - {{br.machine}} - - - {{br.created|date:"d/m/y H:i"}} - - - {{br.updated|date:"d/m/y H:i"}} - - - - - {{br.brerror_set.all.count}} error{{br.brerror_set.all.count|pluralize}} - - - - - {{br.timespent.total_seconds|sectohms}} - - {# we have no output here #} - - - {%endif%} {% endfor %} diff --git a/lib/toaster/toastergui/views.py b/lib/toaster/toastergui/views.py index 7ebcfc115..98d21f404 100755 --- a/lib/toaster/toastergui/views.py +++ b/lib/toaster/toastergui/views.py @@ -33,7 +33,7 @@ from orm.models import Task_Dependency, Recipe_Dependency, Package, Package_File from orm.models import Target_Installed_Package, Target_File, Target_Image_File, BuildArtifact from bldcontrol import bbcontroller from django.views.decorators.cache import cache_control -from django.core.urlresolvers import reverse +from django.core.urlresolvers import reverse, resolve from django.core.exceptions import MultipleObjectsReturned from django.core.paginator import Paginator, EmptyPage, PageNotAnInteger from django.http import HttpResponseBadRequest, HttpResponseNotFound @@ -372,7 +372,6 @@ def _get_queryset(model, queryset, filter_string, search_term, ordering_string, # if the value is given explicitly as a GET parameter it will be the first selected, # otherwise the cookie value will be used. def _get_parameters_values(request, default_count, default_order): - from django.core.urlresolvers import resolve current_url = resolve(request.path_info).url_name pagesize = request.GET.get('count', request.session.get('%s_count' % current_url, default_count)) orderby = request.GET.get('orderby', request.session.get('%s_orderby' % current_url, default_order)) @@ -1894,7 +1893,14 @@ if True: queryset = Build.objects.exclude(outcome = Build.IN_PROGRESS) - context, pagesize, orderby = _build_list_helper(request, queryset) + try: + context, pagesize, orderby = _build_list_helper(request, queryset) + # all builds page as a Project column + context['tablecols'].append({'name': 'Project', 'clcalss': 'project_column', }) + except RedirectException as re: + # rewrite the RedirectException + re.view = resolve(request.path_info).url_name + raise re _set_parameters_values(pagesize, orderby, request) return context @@ -1908,7 +1914,7 @@ if True: mandatory_parameters = { 'count': pagesize, 'page' : 1, 'orderby' : orderby } retval = _verify_parameters( request.GET, mandatory_parameters ) if retval: - raise RedirectException( 'all-builds', request.GET, mandatory_parameters) + raise RedirectException( None, request.GET, mandatory_parameters) # boilerplate code that takes a request for an object type and returns a queryset # for that object type. copypasta for all needed table searches @@ -2083,8 +2089,6 @@ if True: {'name': 'Image files', 'clclass': 'output', 'qhelp': "The root file system types produced by the build. You can find them in your /build/tmp/deploy/images/ directory", # TODO: compute image fstypes from Target_Image_File - }, - {'name': 'Project', 'clcalss': 'project_column', } ] } @@ -2655,7 +2659,13 @@ if True: queryset = Build.objects.filter(outcome__lte = Build.IN_PROGRESS) - context, pagesize, orderby = _build_list_helper(request, queryset) + try: + context, pagesize, orderby = _build_list_helper(request, queryset) + except RedirectException as re: + # rewrite the RedirectException with our current url information + re.view = resolve(request.path_info).url_name + re.okwargs = {"pid" : pid} + raise re context['project'] = prj _set_parameters_values(pagesize, orderby, request) -- cgit 1.2.3-korg