From 05a684f6e590a703ad45eb0c74c65e2ff773781e Mon Sep 17 00:00:00 2001 From: Ravi Chintakunta Date: Tue, 14 Jan 2014 14:06:38 -0500 Subject: 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 Signed-off-by: Alexandru DAMIAN Signed-off-by: Richard Purdie --- .../toaster/toastergui/templatetags/projecttags.py | 35 ++++++++++++++++++++++ 1 file changed, 35 insertions(+) (limited to 'bitbake/lib/toaster/toastergui/templatetags/projecttags.py') diff --git a/bitbake/lib/toaster/toastergui/templatetags/projecttags.py b/bitbake/lib/toaster/toastergui/templatetags/projecttags.py index d57a0598f9..5105be48d2 100644 --- a/bitbake/lib/toaster/toastergui/templatetags/projecttags.py +++ b/bitbake/lib/toaster/toastergui/templatetags/projecttags.py @@ -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 -- cgit v1.2.3-54-g00ecf