diff options
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 | ||