diff options
Diffstat (limited to 'bitbake/lib/toaster/toastergui/widgets.py')
-rw-r--r-- | bitbake/lib/toaster/toastergui/widgets.py | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/bitbake/lib/toaster/toastergui/widgets.py b/bitbake/lib/toaster/toastergui/widgets.py index 82b7514bd8..407a0fbe15 100644 --- a/bitbake/lib/toaster/toastergui/widgets.py +++ b/bitbake/lib/toaster/toastergui/widgets.py | |||
@@ -54,6 +54,13 @@ class ToasterTable(TemplateView): | |||
54 | self.empty_state = "Sorry - no data found" | 54 | self.empty_state = "Sorry - no data found" |
55 | self.default_orderby = "" | 55 | self.default_orderby = "" |
56 | 56 | ||
57 | # add the "id" column, undisplayable, by default | ||
58 | self.add_column(title="Id", | ||
59 | displayable=False, | ||
60 | orderable=True, | ||
61 | field_name="id") | ||
62 | |||
63 | |||
57 | def get(self, request, *args, **kwargs): | 64 | def get(self, request, *args, **kwargs): |
58 | if request.GET.get('format', None) == 'json': | 65 | if request.GET.get('format', None) == 'json': |
59 | 66 | ||
@@ -142,6 +149,7 @@ class ToasterTable(TemplateView): | |||
142 | def add_column(self, title="", help_text="", | 149 | def add_column(self, title="", help_text="", |
143 | orderable=False, hideable=True, hidden=False, | 150 | orderable=False, hideable=True, hidden=False, |
144 | field_name="", filter_name=None, static_data_name=None, | 151 | field_name="", filter_name=None, static_data_name=None, |
152 | displayable=True, computation=None, | ||
145 | static_data_template=None): | 153 | static_data_template=None): |
146 | """Add a column to the table. | 154 | """Add a column to the table. |
147 | 155 | ||
@@ -168,6 +176,8 @@ class ToasterTable(TemplateView): | |||
168 | 'filter_name' : filter_name, | 176 | 'filter_name' : filter_name, |
169 | 'static_data_name': static_data_name, | 177 | 'static_data_name': static_data_name, |
170 | 'static_data_template': static_data_template, | 178 | 'static_data_template': static_data_template, |
179 | 'displayable': displayable, | ||
180 | 'computation': computation, | ||
171 | }) | 181 | }) |
172 | 182 | ||
173 | def render_static_data(self, template, row): | 183 | def render_static_data(self, template, row): |
@@ -289,8 +299,11 @@ class ToasterTable(TemplateView): | |||
289 | 299 | ||
290 | col['field_name'] = col['static_data_name'] | 300 | col['field_name'] = col['static_data_name'] |
291 | 301 | ||
292 | if True: # we add the raw model data at all times | 302 | # compute the computation on the raw data if needed |
293 | model_data = row | 303 | model_data = row |
304 | if col['computation']: | ||
305 | model_data = col['computation'](row) | ||
306 | else: | ||
294 | # Traverse to any foriegn key in the object hierachy | 307 | # Traverse to any foriegn key in the object hierachy |
295 | for subfield in field.split("__"): | 308 | for subfield in field.split("__"): |
296 | if hasattr(model_data, subfield): | 309 | if hasattr(model_data, subfield): |
@@ -300,7 +313,7 @@ class ToasterTable(TemplateView): | |||
300 | if isinstance(model_data, types.MethodType): | 313 | if isinstance(model_data, types.MethodType): |
301 | model_data = model_data() | 314 | model_data = model_data() |
302 | 315 | ||
303 | required_data[field] = model_data | 316 | required_data[col['field_name']] = model_data |
304 | 317 | ||
305 | data['rows'].append(required_data) | 318 | data['rows'].append(required_data) |
306 | 319 | ||