From 4c828782255d1de8fac70757492a331d3d1abdbe Mon Sep 17 00:00:00 2001 From: Michael Wood Date: Tue, 27 Oct 2015 19:04:46 +0000 Subject: [PATCH] bitbake: toaster: ToasterTables simplify filter function move common part to widget Move part of the functionality of the filter functions to the Table widget. We don't need to implement it in each subclass. (Bitbake rev: 16e48829f6fd96c1d21339253871f2a9b2446f87) Signed-off-by: Michael Wood Signed-off-by: brian avery Signed-off-by: Richard Purdie --- bitbake/lib/toaster/toastergui/tables.py | 32 +++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/bitbake/lib/toaster/toastergui/tables.py b/bitbake/lib/toaster/toastergui/tables.py index e9f1fdccb1..7b335c8870 100644 --- a/bitbake/lib/toaster/toastergui/tables.py +++ b/bitbake/lib/toaster/toastergui/tables.py @@ -658,7 +658,37 @@ class SelectPackagesTable(ToasterTable): help_text="Use the add and remove buttons to modify " "the package content of you custom image", static_data_name="add_rm_pkg_btn", - static_data_template='{% include "pkg_add_rm_btn.html" %}') + static_data_template='{% include "pkg_add_rm_btn.html" %}', + static_data_template='{% include "pkg_add_rm_btn.html" %}' + ) + + def setup_filters(self, *args, **kwargs): + project = Project.objects.get(pk=kwargs['pid']) + self.project_layers = ProjectLayer.objects.filter(project=project) + + + self.add_filter(title="Filter by added packages", + name="in_current_image", + filter_actions=[ + self.make_filter_action( + "in_image", + "Packages in %s" % self.cust_recipe.name, + self.filter_in_image), + self.make_filter_action( + "not_in_image", + "Packages not added to %s" % + self.cust_recipe.name, + self.filter_not_in_image) + ]) + + def filter_in_image(self, count_only=False): + return self.queryset.filter( + pk__in=self.static_context_extra['current_packages']) + + + def filter_not_in_image(self, count_only=False): + return self.queryset.exclude( + pk__in=self.static_context_extra['current_packages']) class ProjectsTable(ToasterTable): """Table of projects in Toaster"""