diff options
Diffstat (limited to 'bitbake/lib/toaster/toastergui/widgets.py')
-rw-r--r-- | bitbake/lib/toaster/toastergui/widgets.py | 16 |
1 files changed, 11 insertions, 5 deletions
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 | |||
32 | from django.core.serializers.json import DjangoJSONEncoder | 32 | from django.core.serializers.json import DjangoJSONEncoder |
33 | from django.core.exceptions import FieldError | 33 | from django.core.exceptions import FieldError |
34 | from django.conf.urls import url, patterns | 34 | from django.conf.urls import url, patterns |
35 | from toastergui.querysetfilter import QuerysetFilter | ||
35 | 36 | ||
36 | import types | 37 | import types |
37 | import json | 38 | import json |
@@ -113,7 +114,8 @@ class ToasterTable(TemplateView): | |||
113 | cls=DjangoJSONEncoder) | 114 | cls=DjangoJSONEncoder) |
114 | else: | 115 | else: |
115 | for actions in self.filters[name]['filter_actions']: | 116 | for actions in self.filters[name]['filter_actions']: |
116 | actions['count'] = self.filter_actions[actions['name']](count_only=True) | 117 | queryset_filter = self.filter_actions[actions['name']] |
118 | actions['count'] = queryset_filter.count(self.queryset) | ||
117 | 119 | ||
118 | # Add the "All" items filter action | 120 | # Add the "All" items filter action |
119 | self.filters[name]['filter_actions'].insert(0, { | 121 | self.filters[name]['filter_actions'].insert(0, { |
@@ -151,15 +153,18 @@ class ToasterTable(TemplateView): | |||
151 | 'filter_actions' : filter_actions, | 153 | 'filter_actions' : filter_actions, |
152 | } | 154 | } |
153 | 155 | ||
154 | def make_filter_action(self, name, title, action_function): | 156 | def make_filter_action(self, name, title, queryset_filter): |
155 | """ Utility to make a filter_action """ | 157 | """ |
158 | Utility to make a filter_action; queryset_filter is an instance | ||
159 | of QuerysetFilter or a function | ||
160 | """ | ||
156 | 161 | ||
157 | action = { | 162 | action = { |
158 | 'title' : title, | 163 | 'title' : title, |
159 | 'name' : name, | 164 | 'name' : name, |
160 | } | 165 | } |
161 | 166 | ||
162 | self.filter_actions[name] = action_function | 167 | self.filter_actions[name] = queryset_filter |
163 | 168 | ||
164 | return action | 169 | return action |
165 | 170 | ||
@@ -222,7 +227,8 @@ class ToasterTable(TemplateView): | |||
222 | return | 227 | return |
223 | 228 | ||
224 | try: | 229 | try: |
225 | self.filter_actions[filter_action]() | 230 | queryset_filter = self.filter_actions[filter_action] |
231 | self.queryset = queryset_filter.filter(self.queryset) | ||
226 | except KeyError: | 232 | except KeyError: |
227 | # pass it to the user - programming error here | 233 | # pass it to the user - programming error here |
228 | raise | 234 | raise |