From b929889cdd4a36846f9569d89fabd9987e94b39e Mon Sep 17 00:00:00 2001 From: Elliot Smith Date: Fri, 15 Jan 2016 13:00:52 +0200 Subject: bitbake: toastergui: show recent builds on all builds page The recent builds section was disabled while converting the all builds page to ToasterTable. Re-enable the recent builds area and add the data it requires to the ToasterTable context. [YOCTO #8738] (Bitbake rev: d6df4545bd134a23c9bd3cd1ba3b61ddb26545e4) Signed-off-by: Elliot Smith Signed-off-by: Ed Bartosh Signed-off-by: Richard Purdie --- bitbake/lib/toaster/toastergui/tables.py | 18 +++++++++++++++++- .../toastergui/templates/builds-toastertable.html | 10 +++++----- .../lib/toaster/toastergui/templates/mrb_section.html | 2 +- 3 files changed, 23 insertions(+), 7 deletions(-) (limited to 'bitbake/lib/toaster/toastergui') diff --git a/bitbake/lib/toaster/toastergui/tables.py b/bitbake/lib/toaster/toastergui/tables.py index a0991ec3ea..0941637704 100644 --- a/bitbake/lib/toaster/toastergui/tables.py +++ b/bitbake/lib/toaster/toastergui/tables.py @@ -27,6 +27,7 @@ from django.db.models import Q, Max, Count from django.conf.urls import url from django.core.urlresolvers import reverse from django.views.generic import TemplateView +import itertools from toastergui.tablefilter import TableFilter, TableFilterActionToggle @@ -887,7 +888,22 @@ class BuildsTable(ToasterTable): self.static_context_extra['Task'] = Task def get_context_data(self, **kwargs): - return super(BuildsTable, self).get_context_data(**kwargs) + context = super(BuildsTable, self).get_context_data(**kwargs) + + # for the latest builds section + queryset = Build.objects.all() + + finished_criteria = Q(outcome=Build.SUCCEEDED) | Q(outcome=Build.FAILED) + + latest_builds = itertools.chain( + queryset.filter(outcome=Build.IN_PROGRESS).order_by("-started_on"), + queryset.filter(finished_criteria).order_by("-completed_on")[:3] + ) + + context['mru'] = list(latest_builds) + context['mrb_type'] = 'all' + + return context def setup_queryset(self, *args, **kwargs): queryset = Build.objects.all() diff --git a/bitbake/lib/toaster/toastergui/templates/builds-toastertable.html b/bitbake/lib/toaster/toastergui/templates/builds-toastertable.html index 419d2b52f4..f7604fd7a4 100644 --- a/bitbake/lib/toaster/toastergui/templates/builds-toastertable.html +++ b/bitbake/lib/toaster/toastergui/templates/builds-toastertable.html @@ -3,13 +3,13 @@ {% block title %} All builds - Toaster {% endblock %} {% block pagecontent %} -
- {# TODO need to pass this data to context #} - {#% include 'mrb_section.html' %#} + {% with mru=mru mrb_type=mrb_type %} + {% include 'mrb_section.html' %} + {% endwith %} + +

{% url 'builds' as xhr_table_url %} {% include 'toastertable.html' %} diff --git a/bitbake/lib/toaster/toastergui/templates/mrb_section.html b/bitbake/lib/toaster/toastergui/templates/mrb_section.html index bd8f99178f..52b3f1a7d3 100644 --- a/bitbake/lib/toaster/toastergui/templates/mrb_section.html +++ b/bitbake/lib/toaster/toastergui/templates/mrb_section.html @@ -14,7 +14,7 @@ {% endif %} {% else %} -