summaryrefslogtreecommitdiffstats
path: root/bitbake/lib/toaster/toastergui/views.py
diff options
context:
space:
mode:
Diffstat (limited to 'bitbake/lib/toaster/toastergui/views.py')
-rwxr-xr-xbitbake/lib/toaster/toastergui/views.py48
1 files changed, 43 insertions, 5 deletions
diff --git a/bitbake/lib/toaster/toastergui/views.py b/bitbake/lib/toaster/toastergui/views.py
index 2e52d2bff9..7dc4bbd5a2 100755
--- a/bitbake/lib/toaster/toastergui/views.py
+++ b/bitbake/lib/toaster/toastergui/views.py
@@ -2789,11 +2789,38 @@ if toastermain.settings.MANAGED:
2789 2789
2790 queryset_all = Machine.objects.all() 2790 queryset_all = Machine.objects.all()
2791 2791
2792 queryset_with_search = _get_queryset(Machine, queryset_all, None, search_term, ordering_string, '-name') 2792 prj = Project.objects.get(pk = request.session['project_id'])
2793 queryset = _get_queryset(Machine, queryset_all, filter_string, search_term, ordering_string, '-name') 2793 compatible_layers = prj.compatible_layerversions()
2794 # Make sure we only show machines / layers which are compatible with the current project
2795 queryset_all = queryset_all.filter(layer_version__in=compatible_layers)
2794 2796
2795 project_layers = ProjectLayer.objects.filter(project_id=request.session['project_id']).values_list('layercommit',flat=True) 2797 project_layers = ProjectLayer.objects.filter(project_id=request.session['project_id']).values_list('layercommit',flat=True)
2796 2798
2799 by_pass_filter_string = False
2800 # "special" filters identified by these valid filter strings we
2801 # by pass the usual filter applying method because we're filtering using
2802 # a subquery done by project_layers
2803 if "name:inprj" in filter_string:
2804 queryset_all = queryset_all.filter(layer_version__in=project_layers)
2805 by_pass_filter_string = True
2806
2807 if "name:notinprj" in filter_string:
2808 queryset_all = queryset_all.exclude(layer_version__in=project_layers)
2809 by_pass_filter_string = True
2810
2811 queryset_with_search = _get_queryset(Machine, queryset_all, None, search_term, ordering_string, '-name')
2812
2813 if by_pass_filter_string:
2814 queryset = _get_queryset(Machine, queryset_all, None, search_term, ordering_string, '-name')
2815 else:
2816 queryset = _get_queryset(Machine, queryset_all, filter_string, search_term, ordering_string, '-name')
2817
2818 selected_filter_count = {
2819 'inprj' : queryset.filter(layer_version__in=project_layers).count(),
2820 'notinprj' : queryset.exclude(layer_version__in=project_layers).count()
2821 }
2822
2823
2797 # retrieve the objects that will be displayed in the table; machines a paginator and gets a page range to display 2824 # retrieve the objects that will be displayed in the table; machines a paginator and gets a page range to display
2798 machine_info = _build_page_range(Paginator(queryset, request.GET.get('count', 10)),request.GET.get('page', 1)) 2825 machine_info = _build_page_range(Paginator(queryset, request.GET.get('count', 10)),request.GET.get('page', 1))
2799 2826
@@ -2802,7 +2829,7 @@ if toastermain.settings.MANAGED:
2802 'project_layers' : project_layers, 2829 'project_layers' : project_layers,
2803 'objectname' : "machines", 2830 'objectname' : "machines",
2804 'default_orderby' : 'name:+', 2831 'default_orderby' : 'name:+',
2805 'total_count': queryset_with_search.count(), 2832 'total_count': machine_info.paginator.count,
2806 2833
2807 'tablecols' : [ 2834 'tablecols' : [
2808 { 'name': 'Machine', 2835 { 'name': 'Machine',
@@ -2840,12 +2867,23 @@ if toastermain.settings.MANAGED:
2840 'hidden' : 1, 2867 'hidden' : 1,
2841 }, 2868 },
2842 { 'name': 'Select', 2869 { 'name': 'Select',
2843 'dclass': 'span2', 2870 'dclass': 'select span2',
2844 'qhelp': "Add or delete machines to / from your project ", 2871 'qhelp': "Sets the selected machine as the project machine. You can only have one machine per project",
2872 'filter': {
2873 'class': 'select',
2874 'label': 'Show:',
2875 'options': [
2876 (u'Machines provided by layers added to this project', 'name:inprj', selected_filter_count['inprj']),
2877 (u'Machines provided by layers not added to this project', 'name:notinprj', selected_filter_count['notinprj']),
2878
2879 ],
2880 }
2881
2845 }, 2882 },
2846 2883
2847 ] 2884 ]
2848 } 2885 }
2886
2849 response = render(request, template, context) 2887 response = render(request, template, context)
2850 _save_parameters_cookies(response, pagesize, orderby, request) 2888 _save_parameters_cookies(response, pagesize, orderby, request)
2851 2889