summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Wood <michael.g.wood@intel.com>2015-02-05 18:19:57 +0000
committerRichard Purdie <richard.purdie@linuxfoundation.org>2015-02-10 23:07:50 +0000
commit203ac2937c80b4e5960ea981971d9dbf4ddcd564 (patch)
treecac65aea48869ee85251dff597071afe1d9aabdf
parenta7ab4d03148c4549a2c0c99a5424f04ccecdfcc6 (diff)
downloadpoky-203ac2937c80b4e5960ea981971d9dbf4ddcd564.tar.gz
bitbake: toaster: all Machines exclude de-prioritised layer source items
If a duplicate layer exists from another layer source and provides a machine we don't want to show it if that layer comes from a low priority layer source. (Bitbake rev: ae52f478bbf693b85da21f64835e70825968a305) Signed-off-by: Michael Wood <michael.g.wood@intel.com Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rwxr-xr-xbitbake/lib/toaster/toastergui/views.py33
1 files changed, 22 insertions, 11 deletions
diff --git a/bitbake/lib/toaster/toastergui/views.py b/bitbake/lib/toaster/toastergui/views.py
index 7dc4bbd5a2..88d59f4136 100755
--- a/bitbake/lib/toaster/toastergui/views.py
+++ b/bitbake/lib/toaster/toastergui/views.py
@@ -203,7 +203,6 @@ def _get_search_results(search_term, queryset, model):
203 203
204 search_objects.append(reduce(operator.or_, q_map)) 204 search_objects.append(reduce(operator.or_, q_map))
205 search_object = reduce(operator.and_, search_objects) 205 search_object = reduce(operator.and_, search_objects)
206 print "search objects", search_object
207 queryset = queryset.filter(search_object) 206 queryset = queryset.filter(search_object)
208 207
209 return queryset 208 return queryset
@@ -2788,18 +2787,25 @@ if toastermain.settings.MANAGED:
2788 (filter_string, search_term, ordering_string) = _search_tuple(request, Machine) 2787 (filter_string, search_term, ordering_string) = _search_tuple(request, Machine)
2789 2788
2790 queryset_all = Machine.objects.all() 2789 queryset_all = Machine.objects.all()
2790 queryset_all = queryset_all.prefetch_related('layer_version')
2791 queryset_all = queryset_all.prefetch_related('layer_source')
2791 2792
2792 prj = Project.objects.get(pk = request.session['project_id']) 2793 prj = Project.objects.get(pk = request.session['project_id'])
2793 compatible_layers = prj.compatible_layerversions() 2794 compatible_layers = prj.compatible_layerversions()
2794 # Make sure we only show machines / layers which are compatible with the current project 2795
2796 # FILTERS SECTION
2797
2798 # Make sure we only show machines / layers which are compatible
2799 # with the current project
2795 queryset_all = queryset_all.filter(layer_version__in=compatible_layers) 2800 queryset_all = queryset_all.filter(layer_version__in=compatible_layers)
2796 2801
2797 project_layers = ProjectLayer.objects.filter(project_id=request.session['project_id']).values_list('layercommit',flat=True) 2802 project_layers = ProjectLayer.objects.filter(project_id=request.session['project_id']).values_list('layercommit',flat=True)
2798 2803
2799 by_pass_filter_string = False 2804 by_pass_filter_string = False
2800 # "special" filters identified by these valid filter strings we 2805 # "special" filters identified by these valid filter strings we
2801 # by pass the usual filter applying method because we're filtering using 2806 # by pass the usual filter applying method because we're filtering using
2802 # a subquery done by project_layers 2807 # a subquery done by project_layers
2808
2803 if "name:inprj" in filter_string: 2809 if "name:inprj" in filter_string:
2804 queryset_all = queryset_all.filter(layer_version__in=project_layers) 2810 queryset_all = queryset_all.filter(layer_version__in=project_layers)
2805 by_pass_filter_string = True 2811 by_pass_filter_string = True
@@ -2808,20 +2814,25 @@ if toastermain.settings.MANAGED:
2808 queryset_all = queryset_all.exclude(layer_version__in=project_layers) 2814 queryset_all = queryset_all.exclude(layer_version__in=project_layers)
2809 by_pass_filter_string = True 2815 by_pass_filter_string = True
2810 2816
2811 queryset_with_search = _get_queryset(Machine, queryset_all, None, search_term, ordering_string, '-name') 2817 selected_filter_count = {
2818 'inprj' : queryset_all.filter(layer_version__in=project_layers).count(),
2819 'notinprj' : queryset_all.exclude(layer_version__in=project_layers).count()
2820 }
2821
2822 # END FILTERS
2812 2823
2813 if by_pass_filter_string: 2824 if by_pass_filter_string:
2814 queryset = _get_queryset(Machine, queryset_all, None, search_term, ordering_string, '-name') 2825 queryset = _get_queryset(Machine, queryset_all, None, search_term, ordering_string, '-name')
2815 else: 2826 else:
2816 queryset = _get_queryset(Machine, queryset_all, filter_string, search_term, ordering_string, '-name') 2827 queryset = _get_queryset(Machine, queryset_all, filter_string, search_term, ordering_string, '-name')
2817 2828
2818 selected_filter_count = { 2829 # Now we need to weed out the layers which will appear as duplicated
2819 'inprj' : queryset.filter(layer_version__in=project_layers).count(), 2830 # because they're from a layer source which doesn't need to be used
2820 'notinprj' : queryset.exclude(layer_version__in=project_layers).count() 2831 for machine in queryset:
2821 } 2832 to_rm = machine.layer_version.get_equivalents_wpriority(prj)[1:]
2822 2833 if len(to_rm) > 0:
2834 queryset = queryset.exclude(layer_version__in=to_rm)
2823 2835
2824 # retrieve the objects that will be displayed in the table; machines a paginator and gets a page range to display
2825 machine_info = _build_page_range(Paginator(queryset, request.GET.get('count', 10)),request.GET.get('page', 1)) 2836 machine_info = _build_page_range(Paginator(queryset, request.GET.get('count', 10)),request.GET.get('page', 1))
2826 2837
2827 context = { 2838 context = {
@@ -2854,7 +2865,7 @@ if toastermain.settings.MANAGED:
2854 'filter': { 2865 'filter': {
2855 'class': 'machine', 2866 'class': 'machine',
2856 'label': 'Show:', 2867 'label': 'Show:',
2857 'options': map(lambda x: (x.name, 'layer_source__pk:' + str(x.id), queryset_with_search.filter(layer_source__pk = x.id).count() ), LayerSource.objects.all()), 2868 'options': map(lambda x: (x.name, 'layer_source__pk:' + str(x.id), queryset.filter(layer_source__pk = x.id).count() ), LayerSource.objects.all()),
2858 } 2869 }
2859 }, 2870 },
2860 { 'name': 'Revision', 2871 { 'name': 'Revision',