summaryrefslogtreecommitdiffstats
path: root/poky/bitbake/lib/toaster/toastergui/templatetags/field_values_filter.py
diff options
context:
space:
mode:
Diffstat (limited to 'poky/bitbake/lib/toaster/toastergui/templatetags/field_values_filter.py')
-rw-r--r--poky/bitbake/lib/toaster/toastergui/templatetags/field_values_filter.py18
1 files changed, 18 insertions, 0 deletions
diff --git a/poky/bitbake/lib/toaster/toastergui/templatetags/field_values_filter.py b/poky/bitbake/lib/toaster/toastergui/templatetags/field_values_filter.py
new file mode 100644
index 000000000..5a73af797
--- /dev/null
+++ b/poky/bitbake/lib/toaster/toastergui/templatetags/field_values_filter.py
@@ -0,0 +1,18 @@
+from django import template
+
+register = template.Library()
+
+def field_values(iterable, field):
+ """
+ Convert an iterable of models into a list of strings, one for each model,
+ where the string for each model is the value of the field "field".
+ """
+ objects = []
+
+ if field:
+ for item in iterable:
+ objects.append(getattr(item, field))
+
+ return objects
+
+register.filter('field_values', field_values) \ No newline at end of file
OpenPOWER on IntegriCloud