diff options
author | Michael Wood <michael.g.wood@intel.com> | 2015-05-11 18:51:28 +0100 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2015-05-14 18:04:09 +0100 |
commit | 23f5b009e0ebf59cfcc9ae90a1084468fc88e42f (patch) | |
tree | 06eb458cbd9a95dd635160adac7d90aeae6afea1 /bitbake/lib/toaster/toastergui/tables.py | |
parent | 7f8c44771cc6219ad7e58da7840fffbe93f11b39 (diff) | |
download | poky-23f5b009e0ebf59cfcc9ae90a1084468fc88e42f.tar.gz |
bitbake: toaster: Port All recipes, layers and machines to ToasterTables
Port of the main tables to the new ToasterTable widget.
(Bitbake rev: 6de539d5953b2dca2a9ed75556a59764337a194c)
Signed-off-by: Michael Wood <michael.g.wood@intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake/lib/toaster/toastergui/tables.py')
-rw-r--r-- | bitbake/lib/toaster/toastergui/tables.py | 279 |
1 files changed, 279 insertions, 0 deletions
diff --git a/bitbake/lib/toaster/toastergui/tables.py b/bitbake/lib/toaster/toastergui/tables.py new file mode 100644 index 0000000000..e6395834a5 --- /dev/null +++ b/bitbake/lib/toaster/toastergui/tables.py | |||
@@ -0,0 +1,279 @@ | |||
1 | # | ||
2 | # ex:ts=4:sw=4:sts=4:et | ||
3 | # -*- tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- | ||
4 | # | ||
5 | # BitBake Toaster Implementation | ||
6 | # | ||
7 | # Copyright (C) 2015 Intel Corporation | ||
8 | # | ||
9 | # This program is free software; you can redistribute it and/or modify | ||
10 | # it under the terms of the GNU General Public License version 2 as | ||
11 | # published by the Free Software Foundation. | ||
12 | # | ||
13 | # This program is distributed in the hope that it will be useful, | ||
14 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
15 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
16 | # GNU General Public License for more details. | ||
17 | # | ||
18 | # You should have received a copy of the GNU General Public License along | ||
19 | # with this program; if not, write to the Free Software Foundation, Inc., | ||
20 | # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | ||
21 | |||
22 | from widgets import ToasterTable | ||
23 | from orm.models import Recipe, ProjectLayer, Layer_Version, Machine, Project | ||
24 | from django.db.models import Q, Max | ||
25 | from django.conf.urls import url | ||
26 | from django.views.generic import TemplateView | ||
27 | |||
28 | class LayersTable(ToasterTable): | ||
29 | """Table of layers in Toaster""" | ||
30 | |||
31 | def __init__(self, *args, **kwargs): | ||
32 | ToasterTable.__init__(self) | ||
33 | self.default_orderby = "layer__name" | ||
34 | |||
35 | def setup_queryset(self, *args, **kwargs): | ||
36 | prj = Project.objects.get(pk = kwargs['pid']) | ||
37 | compatible_layers = prj.compatible_layerversions() | ||
38 | |||
39 | self.queryset = compatible_layers.order_by(self.default_orderby) | ||
40 | |||
41 | def setup_columns(self, *args, **kwargs): | ||
42 | |||
43 | layer_link_template = ''' | ||
44 | <a href="{% url 'layerdetails' extra.pid data.id %}"> | ||
45 | {{data.layer.name}} | ||
46 | </a> | ||
47 | ''' | ||
48 | |||
49 | self.add_column(title="Layer", | ||
50 | hideable=False, | ||
51 | orderable=True, | ||
52 | static_data_name="layer__name", | ||
53 | static_data_template=layer_link_template) | ||
54 | |||
55 | self.add_column(title="Summary", | ||
56 | field_name="layer__summary") | ||
57 | |||
58 | git_url_template = ''' | ||
59 | <a href="{% url 'layerdetails' extra.pid data.id %}"> | ||
60 | <code>{{data.layer.vcs_url}}</code> | ||
61 | </a> | ||
62 | {% if data.get_vcs_link_url %} | ||
63 | <a target="_blank" href="{{ data.get_vcs_link_url }}"> | ||
64 | <i class="icon-share get-info"></i> | ||
65 | </a> | ||
66 | {% endif %} | ||
67 | ''' | ||
68 | |||
69 | self.add_column(title="Git repository URL", | ||
70 | help_text="The Git repository for the layer source code", | ||
71 | hidden=True, | ||
72 | static_data_name="git_url", | ||
73 | static_data_template=git_url_template) | ||
74 | |||
75 | git_dir_template = ''' | ||
76 | <a href="{% url 'layerdetails' extra.pid data.id %}"> | ||
77 | <code>{{data.dirpath}}</code> | ||
78 | </a> | ||
79 | {% if data.dirpath and data.get_vcs_dirpath_link_url %} | ||
80 | <a target="_blank" href="{{ data.get_vcs_dirpath_link_url }}"> | ||
81 | <i class="icon-share get-info"></i> | ||
82 | </a> | ||
83 | {% endif %}''' | ||
84 | |||
85 | self.add_column(title="Subdirectory", | ||
86 | help_text="The layer directory within the Git repository", | ||
87 | hidden=True, | ||
88 | static_data_name="git_subdir", | ||
89 | static_data_template=git_dir_template) | ||
90 | |||
91 | revision_template = ''' | ||
92 | {% load projecttags %} | ||
93 | {% with vcs_ref=data.get_vcs_reference %} | ||
94 | {% if vcs_ref|is_shaid %} | ||
95 | <a class="btn" data-content="<ul class='unstyled'> <li>{{vcs_ref}}</li> </ul>"> | ||
96 | {{vcs_ref|truncatechars:10}} | ||
97 | </a> | ||
98 | {% else %} | ||
99 | {{vcs_ref}} | ||
100 | {% endif %} | ||
101 | {% endwith %} | ||
102 | ''' | ||
103 | |||
104 | self.add_column(title="Revision", | ||
105 | help_text="The Git branch, tag or commit. For the layers from the OpenEmbedded layer source, the revision is always the branch compatible with the Yocto Project version you selected for this project", | ||
106 | static_data_name="revision", | ||
107 | static_data_template=revision_template) | ||
108 | |||
109 | deps_template = ''' | ||
110 | {% with ods=data.dependencies.all%} | ||
111 | {% if ods.count %} | ||
112 | <a class="btn" title="<a href='{% url "layerdetails" extra.pid data.id %}'>{{data.layer.name}}</a> dependencies" | ||
113 | data-content="<ul class='unstyled'> | ||
114 | {% for i in ods%} | ||
115 | <li><a href='{% url "layerdetails" extra.pid i.depends_on.pk %}'>{{i.depends_on.layer.name}}</a></li> | ||
116 | {% endfor %} | ||
117 | </ul>"> | ||
118 | {{ods.count}} | ||
119 | </a> | ||
120 | {% endif %} | ||
121 | {% endwith %} | ||
122 | ''' | ||
123 | |||
124 | self.add_column(title="Dependencies", | ||
125 | help_text="Other layers a layer depends upon", | ||
126 | static_data_name="dependencies", | ||
127 | static_data_template=deps_template) | ||
128 | |||
129 | self.add_column(title="Add | Delete", | ||
130 | help_text="Add or delete layers to / from your project", | ||
131 | hideable=False, | ||
132 | static_data_name="add-del-layers", | ||
133 | static_data_template='{% include "layer_btn.html" %}') | ||
134 | |||
135 | |||
136 | class MachinesTable(ToasterTable): | ||
137 | """Table of Machines in Toaster""" | ||
138 | |||
139 | def __init__(self, *args, **kwargs): | ||
140 | ToasterTable.__init__(self) | ||
141 | self.empty_state = "No machines maybe you need to do a build?" | ||
142 | self.default_orderby = "name" | ||
143 | |||
144 | def setup_queryset(self, *args, **kwargs): | ||
145 | prj = Project.objects.get(pk = kwargs['pid']) | ||
146 | compatible_layers = prj.compatible_layerversions() | ||
147 | |||
148 | self.queryset = Machine.objects.filter(layer_version__in=compatible_layers).order_by(self.default_orderby) | ||
149 | |||
150 | def setup_columns(self, *args, **kwargs): | ||
151 | |||
152 | self.add_column(title="Machine", | ||
153 | hideable=False, | ||
154 | orderable=True, | ||
155 | field_name="name") | ||
156 | |||
157 | self.add_column(title="Description", | ||
158 | field_name="description") | ||
159 | |||
160 | layer_link_template = ''' | ||
161 | <a href="{% url 'layerdetails' extra.pid data.layer_version.id %}"> | ||
162 | {{data.layer_version.layer.name}}</a> | ||
163 | ''' | ||
164 | |||
165 | self.add_column(title="Layer", | ||
166 | static_data_name="layer_version__layer__name", | ||
167 | static_data_template=layer_link_template, | ||
168 | orderable=True) | ||
169 | |||
170 | self.add_column(title="Revision", | ||
171 | help_text="The Git branch, tag or commit. For the layers from the OpenEmbedded layer source, the revision is always the branch compatible with the Yocto Project version you selected for this project", | ||
172 | hidden=True, | ||
173 | field_name="layer_version__get_vcs_reference") | ||
174 | |||
175 | machine_file_template = '''<code>conf/machine/{{data.name}}.conf</code> | ||
176 | <a href="{{data.get_vcs_machine_file_link_url}}" target="_blank"><i class="icon-share get-info"></i></a>''' | ||
177 | |||
178 | self.add_column(title="Machine file", | ||
179 | hidden=True, | ||
180 | static_data_name="machinefile", | ||
181 | static_data_template=machine_file_template, | ||
182 | field_name="name") | ||
183 | |||
184 | self.add_column(title="Select", | ||
185 | help_text="Sets the selected machine as the project machine. You can only have one machine per project", | ||
186 | hideable=False, | ||
187 | static_data_name="add-del-layers", | ||
188 | static_data_template='{% include "machine_btn.html" %}', | ||
189 | field_name="layer_version__id") | ||
190 | |||
191 | |||
192 | |||
193 | class RecipesTable(ToasterTable): | ||
194 | """Table of Recipes in Toaster""" | ||
195 | |||
196 | def __init__(self, *args, **kwargs): | ||
197 | ToasterTable.__init__(self) | ||
198 | self.empty_state = "Toaster has no recipe information. To generate recipe information you can configure a layer source then run a build." | ||
199 | self.default_orderby = "name" | ||
200 | |||
201 | def setup_queryset(self, *args, **kwargs): | ||
202 | prj = Project.objects.get(pk = kwargs['pid']) | ||
203 | |||
204 | self.queryset = Recipe.objects.filter(Q(layer_version__up_branch__name= prj.release.name) | Q(layer_version__build__in = prj.build_set.all())).filter(name__regex=r'.{1,}.*') | ||
205 | |||
206 | search_maxids = map(lambda i: i[0], list(self.queryset.values('name').distinct().annotate(max_id=Max('id')).values_list('max_id'))) | ||
207 | |||
208 | self.queryset = self.queryset.filter(id__in=search_maxids).select_related('layer_version', 'layer_version__layer', 'layer_version__up_branch', 'layer_source') | ||
209 | self.queryset = self.queryset.order_by(self.default_orderby) | ||
210 | |||
211 | |||
212 | def setup_columns(self, *args, **kwargs): | ||
213 | |||
214 | self.add_column(title="Recipe", | ||
215 | help_text="Information about a single piece of software, including where to download the source, configuration options, how to compile the source files and how to package the compiled output", | ||
216 | hideable=False, | ||
217 | orderable=True, | ||
218 | field_name="name") | ||
219 | |||
220 | self.add_column(title="Recipe Version", | ||
221 | hidden=True, | ||
222 | field_name="version") | ||
223 | |||
224 | self.add_column(title="Description", | ||
225 | field_name="get_description_or_summary") | ||
226 | |||
227 | recipe_file_template = ''' | ||
228 | <code>{{data.file_path}}</code> | ||
229 | <a href="{{data.get_vcs_recipe_file_link_url}}" target="_blank"> | ||
230 | <i class="icon-share get-info"></i> | ||
231 | </a> | ||
232 | ''' | ||
233 | |||
234 | self.add_column(title="Recipe file", | ||
235 | help_text="Path to the recipe .bb file", | ||
236 | static_data_name="recipe-file", | ||
237 | static_data_template=recipe_file_template) | ||
238 | |||
239 | self.add_column(title="Section", | ||
240 | help_text="The section in which recipes should be categorized", | ||
241 | orderable=True, | ||
242 | field_name="section") | ||
243 | |||
244 | layer_link_template = ''' | ||
245 | <a href="{% url 'layerdetails' extra.pid data.layer_version.id %}"> | ||
246 | {{data.layer_version.layer.name}}</a> | ||
247 | ''' | ||
248 | |||
249 | self.add_column(title="Layer", | ||
250 | help_text="The name of the layer providing the recipe", | ||
251 | orderable=True, | ||
252 | static_data_name="layer_version__layer__name", | ||
253 | static_data_template=layer_link_template) | ||
254 | |||
255 | self.add_column(title="License", | ||
256 | help_text="The list of source licenses for the recipe. Multiple license names separated by the pipe character indicates a choice between licenses. Multiple license names separated by the ampersand character indicates multiple licenses exist that cover different parts of the source", | ||
257 | orderable=True, | ||
258 | field_name="license") | ||
259 | |||
260 | self.add_column(title="Revision", | ||
261 | field_name="layer_version__get_vcs_reference") | ||
262 | |||
263 | |||
264 | self.add_column(title="Build", | ||
265 | help_text="Add or delete recipes to and from your project", | ||
266 | hideable=False, | ||
267 | static_data_name="add-del-layers", | ||
268 | static_data_template='{% include "recipe_btn.html" %}') | ||
269 | |||
270 | # This needs to be staticaly defined here as django reads the url patterns | ||
271 | # on start up | ||
272 | urlpatterns = ( | ||
273 | url(r'^machines/(?P<cmd>\w+)*', MachinesTable.as_view(), | ||
274 | name=MachinesTable.__name__.lower()), | ||
275 | url(r'^layers/(?P<cmd>\w+)*', LayersTable.as_view(), | ||
276 | name=LayersTable.__name__.lower()), | ||
277 | url(r'^recipes/(?P<cmd>\w+)*', RecipesTable.as_view(), | ||
278 | name=RecipesTable.__name__.lower()), | ||
279 | ) | ||