1
0
mirror of https://git.yoctoproject.org/poky synced 2026-05-09 05:29:32 +00:00

bitbake: toaster: Added custom filter tags for use in templates.

- custom filter tag to return the css class based on
  the task execution status and execution outcome

- custom filters for active filter icon and tooltip text

- custom filter for displaying blank for None, zero, '0' and
  'Not Applicable'

(Bitbake rev: 1e9253984e6f107c6eed1c3b9df3a444076e2989)

Signed-off-by: Ravi Chintakunta <ravi.chintakunta@timesys.com>
Signed-off-by: Alexandru DAMIAN <alexandru.damian@intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
This commit is contained in:
Ravi Chintakunta
2014-01-14 14:06:38 -05:00
committed by Richard Purdie
parent 87776ca32e
commit 05a684f6e5
@@ -66,3 +66,38 @@ def datecompute(delta, start = timezone.now()):
@register.filter(name = 'sortcols')
def sortcols(tablecols):
return sorted(tablecols, key = lambda t: t['name'])
@register.filter
def task_color(task_object):
""" Return css class depending on Task execution status and execution outcome
"""
if not task_object.task_executed:
return 'class=muted'
elif task_object.get_outcome_display == 'Failed':
return 'class=error'
else:
return ''
@register.filter
def filtered_icon(options, filter):
"""Returns btn-primary if the filter matches one of the filter options
"""
for option in options:
if filter == option[1]:
return "btn-primary"
return ""
@register.filter
def filtered_tooltip(options, filter):
"""Returns tooltip for the filter icon if the filter matches one of the filter options
"""
for option in options:
if filter == option[1]:
return "Showing only %s"%option[0]
return ""
@register.filter
def format_none_and_zero(value):
"""Return empty string if the value is None, zero or Not Applicable
"""
return "" if (not value) or (value == 0) or (value == "0") or (value == 'Not Applicable') else value