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.py173
1 files changed, 167 insertions, 6 deletions
diff --git a/bitbake/lib/toaster/toastergui/views.py b/bitbake/lib/toaster/toastergui/views.py
index 86a34adf24..167b687d03 100755
--- a/bitbake/lib/toaster/toastergui/views.py
+++ b/bitbake/lib/toaster/toastergui/views.py
@@ -1761,7 +1761,7 @@ if toastermain.settings.MANAGED:
1761 from django.contrib.auth.decorators import login_required 1761 from django.contrib.auth.decorators import login_required
1762 1762
1763 from orm.models import Project, ProjectLayer, ProjectTarget, ProjectVariable 1763 from orm.models import Project, ProjectLayer, ProjectTarget, ProjectVariable
1764 from orm.models import Branch, LayerSource, ToasterSetting, Release 1764 from orm.models import Branch, LayerSource, ToasterSetting, Release, Machine
1765 from bldcontrol.models import BuildRequest 1765 from bldcontrol.models import BuildRequest
1766 1766
1767 import traceback 1767 import traceback
@@ -1770,10 +1770,13 @@ if toastermain.settings.MANAGED:
1770 1770
1771 # the context processor that supplies data used across all the pages 1771 # the context processor that supplies data used across all the pages
1772 def managedcontextprocessor(request): 1772 def managedcontextprocessor(request):
1773 return { 1773 ret = {
1774 "projects": Project.objects.all(), 1774 "projects": Project.objects.all(),
1775 "MANAGED" : toastermain.settings.MANAGED 1775 "MANAGED" : toastermain.settings.MANAGED
1776 } 1776 }
1777 if 'project' in request.session:
1778 ret['project'] = request.session['project']
1779 return ret
1777 1780
1778 # new project 1781 # new project
1779 def newproject(request): 1782 def newproject(request):
@@ -1922,7 +1925,7 @@ if toastermain.settings.MANAGED:
1922 # define here what parameters the view needs in the GET portion in order to 1925 # define here what parameters the view needs in the GET portion in order to
1923 # be able to display something. 'count' and 'page' are mandatory for all views 1926 # be able to display something. 'count' and 'page' are mandatory for all views
1924 # that use paginators. 1927 # that use paginators.
1925 mandatory_parameters = { 'count': 10, 'page' : 1, 'orderby' : 'layer__name:-' }; 1928 mandatory_parameters = { 'count': 10, 'page' : 1, 'orderby' : 'layer__name:+' };
1926 retval = _verify_parameters( request.GET, mandatory_parameters ) 1929 retval = _verify_parameters( request.GET, mandatory_parameters )
1927 if retval: 1930 if retval:
1928 return _redirect_parameters( 'layers', request.GET, mandatory_parameters) 1931 return _redirect_parameters( 'layers', request.GET, mandatory_parameters)
@@ -1945,7 +1948,8 @@ if toastermain.settings.MANAGED:
1945 context = { 1948 context = {
1946 'objects' : layer_info, 1949 'objects' : layer_info,
1947 'objectname' : "layers", 1950 'objectname' : "layers",
1948 'default_orderby' : 'completed_on:-', 1951 'default_orderby' : 'layer__name:+',
1952 'total_count': queryset_with_search.count(),
1949 1953
1950 'tablecols' : [ 1954 'tablecols' : [
1951 { 'name': 'Layer', 1955 { 'name': 'Layer',
@@ -1954,8 +1958,10 @@ if toastermain.settings.MANAGED:
1954 }, 1958 },
1955 { 'name': 'Description', 1959 { 'name': 'Description',
1956 'dclass': 'span4', 1960 'dclass': 'span4',
1961 'clclass': 'description',
1957 }, 1962 },
1958 { 'name': 'Layer source', 1963 { 'name': 'Layer source',
1964 'clclass': 'source',
1959 'qhelp': "Where the layer is coming from, for example, if it's part of the OpenEmbedded collection of layers or if it's a layer you have imported", 1965 'qhelp': "Where the layer is coming from, for example, if it's part of the OpenEmbedded collection of layers or if it's a layer you have imported",
1960 'orderfield': _get_toggle_order(request, "layer_source__name"), 1966 'orderfield': _get_toggle_order(request, "layer_source__name"),
1961 'ordericon': _get_toggle_order_icon(request, "layer_source__name"), 1967 'ordericon': _get_toggle_order_icon(request, "layer_source__name"),
@@ -1967,15 +1973,20 @@ if toastermain.settings.MANAGED:
1967 }, 1973 },
1968 { 'name': 'Git repository URL', 1974 { 'name': 'Git repository URL',
1969 'dclass': 'span6', 1975 'dclass': 'span6',
1976 'clclass': 'git-repo', 'hidden': 1,
1970 'qhelp': "The Git repository for the layer source code", 1977 'qhelp': "The Git repository for the layer source code",
1971 }, 1978 },
1972 { 'name': 'Subdirectory', 1979 { 'name': 'Subdirectory',
1980 'clclass': 'git-subdir',
1981 'hidden': 1,
1973 'qhelp': "The layer directory within the Git repository", 1982 'qhelp': "The layer directory within the Git repository",
1974 }, 1983 },
1975 { 'name': 'Branch, tag o commit', 1984 { 'name': 'Branch, tag o commit',
1985 'clclass': 'branch',
1976 'qhelp': "The Git branch of the layer. For the layers from the OpenEmbedded source, the branch matches the Yocto Project version you selected for this project", 1986 'qhelp': "The Git branch of the layer. For the layers from the OpenEmbedded source, the branch matches the Yocto Project version you selected for this project",
1977 }, 1987 },
1978 { 'name': 'Dependencies', 1988 { 'name': 'Dependencies',
1989 'clclass': 'dependencies',
1979 'qhelp': "Other layers a layer depends upon", 1990 'qhelp': "Other layers a layer depends upon",
1980 }, 1991 },
1981 { 'name': 'Add | Delete', 1992 { 'name': 'Add | Delete',
@@ -1992,10 +2003,160 @@ if toastermain.settings.MANAGED:
1992 raise Exception("TODO: implement page #6591") 2003 raise Exception("TODO: implement page #6591")
1993 2004
1994 def targets(request): 2005 def targets(request):
1995 raise Exception("TODO: implement page #6592") 2006 template = "targets.html"
2007 # define here what parameters the view needs in the GET portion in order to
2008 # be able to display something. 'count' and 'page' are mandatory for all views
2009 # that use paginators.
2010 mandatory_parameters = { 'count': 10, 'page' : 1, 'orderby' : 'name:+' };
2011 retval = _verify_parameters( request.GET, mandatory_parameters )
2012 if retval:
2013 return _redirect_parameters( 'targets', request.GET, mandatory_parameters)
2014
2015 # boilerplate code that takes a request for an object type and returns a queryset
2016 # for that object type. copypasta for all needed table searches
2017 (filter_string, search_term, ordering_string) = _search_tuple(request, Recipe)
2018
2019 queryset_all = Recipe.objects.all()
2020 if 'project' in request.session:
2021 queryset_all = queryset_all.filter(Q(layer_version__up_branch__in = Branch.objects.filter(name = request.session['project'].release.name)) | Q(layer_version__build__in = request.session['project'].build_set.all()))
2022
2023 queryset_with_search = _get_queryset(Recipe, queryset_all, None, search_term, ordering_string, '-name')
2024 queryset = _get_queryset(Recipe, queryset_all, filter_string, search_term, ordering_string, '-name')
2025
2026 # retrieve the objects that will be displayed in the table; targets a paginator and gets a page range to display
2027 target_info = _build_page_range(Paginator(queryset, request.GET.get('count', 10)),request.GET.get('page', 1))
2028
2029
2030 context = {
2031 'objects' : target_info,
2032 'objectname' : "targets",
2033 'default_orderby' : 'name:+',
2034 'total_count': queryset_with_search.count(),
2035
2036 'tablecols' : [
2037 { 'name': 'Target',
2038 'orderfield': _get_toggle_order(request, "name"),
2039 'ordericon' : _get_toggle_order_icon(request, "name"),
2040 },
2041 { 'name': 'Target version',
2042 'dclass': 'span2',
2043 },
2044 { 'name': 'Description',
2045 'dclass': 'span5',
2046 'clclass': 'description',
2047 },
2048 { 'name': 'Recipe file',
2049 'clclass': 'recipe-file',
2050 'hidden': 1,
2051 'dclass': 'span5',
2052 },
2053 { 'name': 'Section',
2054 'clclass': 'target-section',
2055 'hidden': 1,
2056 },
2057 { 'name': 'License',
2058 'clclass': 'license',
2059 'hidden': 1,
2060 },
2061 { 'name': 'Layer',
2062 'clclass': 'layer',
2063 },
2064 { 'name': 'Layer source',
2065 'clclass': 'source',
2066 'qhelp': "Where the target is coming from, for example, if it's part of the OpenEmbedded collection of targets or if it's a target you have imported",
2067 'orderfield': _get_toggle_order(request, "layer_source__name"),
2068 'ordericon': _get_toggle_order_icon(request, "layer_source__name"),
2069 'filter': {
2070 'class': 'target',
2071 'label': 'Show:',
2072 '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()),
2073 }
2074 },
2075 { 'name': 'Branch, tag or commit',
2076 'clclass': 'branch',
2077 'hidden': 1,
2078 },
2079 { 'name': 'Build',
2080 'dclass': 'span2',
2081 'qhelp': "Add or delete targets to / from your project ",
2082 },
2083
2084 ]
2085 }
2086
2087 return render(request, template, context)
1996 2088
1997 def machines(request): 2089 def machines(request):
1998 raise Exception("TODO: implement page #6593") 2090 template = "machines.html"
2091 # define here what parameters the view needs in the GET portion in order to
2092 # be able to display something. 'count' and 'page' are mandatory for all views
2093 # that use paginators.
2094 mandatory_parameters = { 'count': 10, 'page' : 1, 'orderby' : 'name:+' };
2095 retval = _verify_parameters( request.GET, mandatory_parameters )
2096 if retval:
2097 return _redirect_parameters( 'machines', request.GET, mandatory_parameters)
2098
2099 # boilerplate code that takes a request for an object type and returns a queryset
2100 # for that object type. copypasta for all needed table searches
2101 (filter_string, search_term, ordering_string) = _search_tuple(request, Machine)
2102
2103 queryset_all = Machine.objects.all()
2104# if 'project' in request.session:
2105# queryset_all = queryset_all.filter(Q(layer_version__up_branch__in = Branch.objects.filter(name = request.session['project'].release.name)) | Q(layer_version__build__in = request.session['project'].build_set.all()))
2106
2107 queryset_with_search = _get_queryset(Machine, queryset_all, None, search_term, ordering_string, '-name')
2108 queryset = _get_queryset(Machine, queryset_all, filter_string, search_term, ordering_string, '-name')
2109
2110 # retrieve the objects that will be displayed in the table; machines a paginator and gets a page range to display
2111 machine_info = _build_page_range(Paginator(queryset, request.GET.get('count', 10)),request.GET.get('page', 1))
2112
2113
2114 context = {
2115 'objects' : machine_info,
2116 'objectname' : "machines",
2117 'default_orderby' : 'name:+',
2118 'total_count': queryset_with_search.count(),
2119
2120 'tablecols' : [
2121 { 'name': 'Machine',
2122 'orderfield': _get_toggle_order(request, "name"),
2123 'ordericon' : _get_toggle_order_icon(request, "name"),
2124 },
2125 { 'name': 'Description',
2126 'dclass': 'span5',
2127 'clclass': 'description',
2128 },
2129 { 'name': 'Machine file',
2130 'clclass': 'machine-file',
2131 'hidden': 1,
2132 },
2133 { 'name': 'Layer',
2134 'clclass': 'layer',
2135 },
2136 { 'name': 'Layer source',
2137 'clclass': 'source',
2138 'qhelp': "Where the machine is coming from, for example, if it's part of the OpenEmbedded collection of machines or if it's a machine you have imported",
2139 'orderfield': _get_toggle_order(request, "layer_source__name"),
2140 'ordericon': _get_toggle_order_icon(request, "layer_source__name"),
2141 'filter': {
2142 'class': 'machine',
2143 'label': 'Show:',
2144 '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()),
2145 }
2146 },
2147 { 'name': 'Branch, tag or commit',
2148 'clclass': 'branch',
2149 'hidden': 1,
2150 },
2151 { 'name': 'Select',
2152 'dclass': 'span2',
2153 'qhelp': "Add or delete machines to / from your project ",
2154 },
2155
2156 ]
2157 }
2158
2159 return render(request, template, context)
1999 2160
2000 def projectconf(request, pid): 2161 def projectconf(request, pid):
2001 raise Exception("TODO: implement page #6588") 2162 raise Exception("TODO: implement page #6588")