From 294579b531d5a96a17aa863554e71f4680d35812 Mon Sep 17 00:00:00 2001 From: Elliot Smith Date: Fri, 15 Jan 2016 13:00:49 +0200 Subject: bitbake: toastergui: convert all builds page to ToasterTable For better long-term maintainability, use ToasterTable instead of Django template and view code to display the all builds page. NB the builds.html template has been left in, as this will otherwise cause conflicts when merging the new theme. [YOCTO #8738] (Bitbake rev: e0590fc8103afeb4c5e613a826057555c8193d59) Signed-off-by: Elliot Smith Signed-off-by: Ed Bartosh Signed-off-by: Richard Purdie --- bitbake/lib/toaster/toastergui/widgets.py | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) (limited to 'bitbake/lib/toaster/toastergui/widgets.py') diff --git a/bitbake/lib/toaster/toastergui/widgets.py b/bitbake/lib/toaster/toastergui/widgets.py index 6bb388936c..71b29eaa1e 100644 --- a/bitbake/lib/toaster/toastergui/widgets.py +++ b/bitbake/lib/toaster/toastergui/widgets.py @@ -32,6 +32,7 @@ from django.template import Context, Template from django.core.serializers.json import DjangoJSONEncoder from django.core.exceptions import FieldError from django.conf.urls import url, patterns +from toastergui.querysetfilter import QuerysetFilter import types import json @@ -113,7 +114,8 @@ class ToasterTable(TemplateView): cls=DjangoJSONEncoder) else: for actions in self.filters[name]['filter_actions']: - actions['count'] = self.filter_actions[actions['name']](count_only=True) + queryset_filter = self.filter_actions[actions['name']] + actions['count'] = queryset_filter.count(self.queryset) # Add the "All" items filter action self.filters[name]['filter_actions'].insert(0, { @@ -151,15 +153,18 @@ class ToasterTable(TemplateView): 'filter_actions' : filter_actions, } - def make_filter_action(self, name, title, action_function): - """ Utility to make a filter_action """ + def make_filter_action(self, name, title, queryset_filter): + """ + Utility to make a filter_action; queryset_filter is an instance + of QuerysetFilter or a function + """ action = { 'title' : title, 'name' : name, } - self.filter_actions[name] = action_function + self.filter_actions[name] = queryset_filter return action @@ -222,7 +227,8 @@ class ToasterTable(TemplateView): return try: - self.filter_actions[filter_action]() + queryset_filter = self.filter_actions[filter_action] + self.queryset = queryset_filter.filter(self.queryset) except KeyError: # pass it to the user - programming error here raise -- cgit v1.2.3-54-g00ecf