diff options
author | Elliot Smith <elliot.smith@intel.com> | 2016-01-18 14:23:55 +0000 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2016-02-10 13:29:20 +0000 |
commit | efbffe3c298d57af34324639f2208e35735758a9 (patch) | |
tree | 211cb0601b9b1ed6fe6ad220cb03818080a3d725 /bitbake/lib/toaster/toastergui/tables.py | |
parent | b51478582f17bc9c43a92232e41246aec3e89f36 (diff) | |
download | poky-efbffe3c298d57af34324639f2208e35735758a9.tar.gz |
bitbake: toaster: move recent builds query to model
The progress updater for the recent builds section makes a JSON
call to the project view URL to get progress for each build.
However, conversion of the builds pages to ToasterTable broke this,
as the JSON response no longer contained the data necessary to
populate the progress bars.
Move the recent builds query to the Build model, so that it is
accessible to the ToasterTables using it ("project builds" and
"all builds"), as well as to the "project" view.
Modify the code in the recent builds template to use the slightly
different objects returned by the recent builds query on Build.
(Bitbake rev: 5189252635ddc7b90c9a43aaed9f196c31e1dcad)
Signed-off-by: Elliot Smith <elliot.smith@intel.com>
Signed-off-by: brian avery <avery.brian@gmail.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake/lib/toaster/toastergui/tables.py')
-rw-r--r-- | bitbake/lib/toaster/toastergui/tables.py | 33 |
1 files changed, 14 insertions, 19 deletions
diff --git a/bitbake/lib/toaster/toastergui/tables.py b/bitbake/lib/toaster/toastergui/tables.py index ba2726d070..7fb3f8605e 100644 --- a/bitbake/lib/toaster/toastergui/tables.py +++ b/bitbake/lib/toaster/toastergui/tables.py | |||
@@ -28,7 +28,6 @@ from django.conf.urls import url | |||
28 | from django.core.urlresolvers import reverse, resolve | 28 | from django.core.urlresolvers import reverse, resolve |
29 | from django.http import HttpResponse | 29 | from django.http import HttpResponse |
30 | from django.views.generic import TemplateView | 30 | from django.views.generic import TemplateView |
31 | import itertools | ||
32 | 31 | ||
33 | from toastergui.tablefilter import TableFilter | 32 | from toastergui.tablefilter import TableFilter |
34 | from toastergui.tablefilter import TableFilterActionToggle | 33 | from toastergui.tablefilter import TableFilterActionToggle |
@@ -1060,17 +1059,9 @@ class BuildsTable(ToasterTable): | |||
1060 | def get_context_data(self, **kwargs): | 1059 | def get_context_data(self, **kwargs): |
1061 | context = super(BuildsTable, self).get_context_data(**kwargs) | 1060 | context = super(BuildsTable, self).get_context_data(**kwargs) |
1062 | 1061 | ||
1063 | # for the latest builds section | 1062 | # should be set in subclasses |
1064 | builds = self.get_builds() | 1063 | context['mru'] = [] |
1065 | 1064 | ||
1066 | finished_criteria = Q(outcome=Build.SUCCEEDED) | Q(outcome=Build.FAILED) | ||
1067 | |||
1068 | latest_builds = itertools.chain( | ||
1069 | builds.filter(outcome=Build.IN_PROGRESS).order_by("-started_on"), | ||
1070 | builds.filter(finished_criteria).order_by("-completed_on")[:3] | ||
1071 | ) | ||
1072 | |||
1073 | context['mru'] = list(latest_builds) | ||
1074 | context['mrb_type'] = self.mrb_type | 1065 | context['mrb_type'] = self.mrb_type |
1075 | 1066 | ||
1076 | return context | 1067 | return context |
@@ -1481,6 +1472,12 @@ class AllBuildsTable(BuildsTable): | |||
1481 | static_data_name='project', | 1472 | static_data_name='project', |
1482 | static_data_template=project_template) | 1473 | static_data_template=project_template) |
1483 | 1474 | ||
1475 | def get_context_data(self, **kwargs): | ||
1476 | """ Get all builds for the recent builds area """ | ||
1477 | context = super(AllBuildsTable, self).get_context_data(**kwargs) | ||
1478 | context['mru'] = Build.get_recent() | ||
1479 | return context | ||
1480 | |||
1484 | class ProjectBuildsTable(BuildsTable): | 1481 | class ProjectBuildsTable(BuildsTable): |
1485 | """ | 1482 | """ |
1486 | Builds page for a single project; a BuildsTable, with the queryset | 1483 | Builds page for a single project; a BuildsTable, with the queryset |
@@ -1521,18 +1518,16 @@ class ProjectBuildsTable(BuildsTable): | |||
1521 | 1518 | ||
1522 | def get_context_data(self, **kwargs): | 1519 | def get_context_data(self, **kwargs): |
1523 | """ | 1520 | """ |
1521 | Get recent builds for this project, and the project itself | ||
1522 | |||
1524 | NOTE: self.project_id must be set before calling super(), | 1523 | NOTE: self.project_id must be set before calling super(), |
1525 | as it's used in get_context_data() | 1524 | as it's used in get_context_data() |
1526 | """ | 1525 | """ |
1527 | self.project_id = kwargs['pid'] | 1526 | self.project_id = kwargs['pid'] |
1528 | |||
1529 | context = super(ProjectBuildsTable, self).get_context_data(**kwargs) | 1527 | context = super(ProjectBuildsTable, self).get_context_data(**kwargs) |
1530 | context['project'] = Project.objects.get(pk=self.project_id) | ||
1531 | |||
1532 | return context | ||
1533 | |||
1534 | def get_builds(self): | ||
1535 | """ override: only return builds for the relevant project """ | ||
1536 | 1528 | ||
1537 | project = Project.objects.get(pk=self.project_id) | 1529 | project = Project.objects.get(pk=self.project_id) |
1538 | return Build.objects.filter(project=project) | 1530 | context['mru'] = Build.get_recent(project) |
1531 | context['project'] = project | ||
1532 | |||
1533 | return context | ||