summaryrefslogtreecommitdiffstats
path: root/lib/toaster/toastergui/templatetags
diff options
context:
space:
mode:
authorRavi Chintakunta <ravi.chintakunta@timesys.com>2014-01-14 14:06:38 -0500
committerAlexandru DAMIAN <alexandru.damian@intel.com>2014-01-27 15:19:49 +0000
commit1e9253984e6f107c6eed1c3b9df3a444076e2989 (patch)
treed8bcb4f6393bc82a8e41409ee21fa097429399ef /lib/toaster/toastergui/templatetags
parent53ede15926d45b555252d77919a0568a984c6d74 (diff)
downloadbitbake-contrib-1e9253984e6f107c6eed1c3b9df3a444076e2989.tar.gz
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' Signed-off-by: Ravi Chintakunta <ravi.chintakunta@timesys.com> Signed-off-by: Alexandru DAMIAN <alexandru.damian@intel.com>
Diffstat (limited to 'lib/toaster/toastergui/templatetags')
-rw-r--r--lib/toaster/toastergui/templatetags/projecttags.py35
1 files changed, 35 insertions, 0 deletions
diff --git a/lib/toaster/toastergui/templatetags/projecttags.py b/lib/toaster/toastergui/templatetags/projecttags.py
index d57a0598f..5105be48d 100644
--- a/lib/toaster/toastergui/templatetags/projecttags.py
+++ b/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