diff options
Diffstat (limited to 'bitbake/lib')
-rw-r--r-- | bitbake/lib/toaster/toastergui/templatetags/projecttags.py | 35 |
1 files changed, 35 insertions, 0 deletions
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()): | |||
66 | @register.filter(name = 'sortcols') | 66 | @register.filter(name = 'sortcols') |
67 | def sortcols(tablecols): | 67 | def sortcols(tablecols): |
68 | return sorted(tablecols, key = lambda t: t['name']) | 68 | return sorted(tablecols, key = lambda t: t['name']) |
69 | |||
70 | @register.filter | ||
71 | def task_color(task_object): | ||
72 | """ Return css class depending on Task execution status and execution outcome | ||
73 | """ | ||
74 | if not task_object.task_executed: | ||
75 | return 'class=muted' | ||
76 | elif task_object.get_outcome_display == 'Failed': | ||
77 | return 'class=error' | ||
78 | else: | ||
79 | return '' | ||
80 | |||
81 | @register.filter | ||
82 | def filtered_icon(options, filter): | ||
83 | """Returns btn-primary if the filter matches one of the filter options | ||
84 | """ | ||
85 | for option in options: | ||
86 | if filter == option[1]: | ||
87 | return "btn-primary" | ||
88 | return "" | ||
89 | |||
90 | @register.filter | ||
91 | def filtered_tooltip(options, filter): | ||
92 | """Returns tooltip for the filter icon if the filter matches one of the filter options | ||
93 | """ | ||
94 | for option in options: | ||
95 | if filter == option[1]: | ||
96 | return "Showing only %s"%option[0] | ||
97 | return "" | ||
98 | |||
99 | @register.filter | ||
100 | def format_none_and_zero(value): | ||
101 | """Return empty string if the value is None, zero or Not Applicable | ||
102 | """ | ||
103 | return "" if (not value) or (value == 0) or (value == "0") or (value == 'Not Applicable') else value | ||