summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Wood <michael.g.wood@intel.com>2016-07-21 14:43:27 +0100
committerRichard Purdie <richard.purdie@linuxfoundation.org>2016-07-26 08:10:36 +0100
commitef627d0ab8f5cf2fc72005393e76047cb623ff3d (patch)
treeae0067545010621d688baea77197ec50c7db7acc
parentffc78d329d6fed9ae9a0db470d30033069b42f8f (diff)
downloadpoky-ef627d0ab8f5cf2fc72005393e76047cb623ff3d.tar.gz
bitbake: toaster: Replace references to LayerSource models
Replace references to the now deprecated layersource models across Toaster with the new enums for layer source types. (Bitbake rev: 48c09c62eb979d840132e58144f0d81ffee675b1) Signed-off-by: Michael Wood <michael.g.wood@intel.com> Signed-off-by: Elliot Smith <elliot.smith@intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rw-r--r--bitbake/lib/toaster/bldcontrol/tests.py19
-rw-r--r--bitbake/lib/toaster/orm/models.py8
-rw-r--r--bitbake/lib/toaster/tests/browser/test_layerdetails_page.py3
-rw-r--r--bitbake/lib/toaster/toastergui/api.py6
-rw-r--r--bitbake/lib/toaster/toastergui/static/js/layerdetails.js2
-rw-r--r--bitbake/lib/toaster/toastergui/templates/layerdetails.html16
-rwxr-xr-xbitbake/lib/toaster/toastergui/views.py56
7 files changed, 57 insertions, 53 deletions
diff --git a/bitbake/lib/toaster/bldcontrol/tests.py b/bitbake/lib/toaster/bldcontrol/tests.py
index 32985c3280..475ac0a16f 100644
--- a/bitbake/lib/toaster/bldcontrol/tests.py
+++ b/bitbake/lib/toaster/bldcontrol/tests.py
@@ -139,22 +139,3 @@ class RunBuildsCommandTests(TestCase):
139 self.assertTrue(br.state == BuildRequest.REQ_INPROGRESS, "Request is not updated") 139 self.assertTrue(br.state == BuildRequest.REQ_INPROGRESS, "Request is not updated")
140 # no more selections possible here 140 # no more selections possible here
141 self.assertRaises(IndexError, command._selectBuildRequest) 141 self.assertRaises(IndexError, command._selectBuildRequest)
142
143
144class UtilityTests(TestCase):
145 def test_reduce_path(self):
146 from bldcontrol.management.commands.loadconf import _reduce_canon_path, _get_id_for_sourcetype
147
148 self.assertTrue( _reduce_canon_path("/") == "/")
149 self.assertTrue( _reduce_canon_path("/home/..") == "/")
150 self.assertTrue( _reduce_canon_path("/home/../ana") == "/ana")
151 self.assertTrue( _reduce_canon_path("/home/../ana/..") == "/")
152 self.assertTrue( _reduce_canon_path("/home/ana/mihai/../maria") == "/home/ana/maria")
153
154 def test_get_id_for_sorucetype(self):
155 from bldcontrol.management.commands.loadconf import _reduce_canon_path, _get_id_for_sourcetype
156 self.assertTrue( _get_id_for_sourcetype("layerindex") == 1)
157 self.assertTrue( _get_id_for_sourcetype("local") == 0)
158 self.assertTrue( _get_id_for_sourcetype("imported") == 2)
159 with self.assertRaises(Exception):
160 _get_id_for_sourcetype("unknown")
diff --git a/bitbake/lib/toaster/orm/models.py b/bitbake/lib/toaster/orm/models.py
index 1daec9c25a..34ea28c270 100644
--- a/bitbake/lib/toaster/orm/models.py
+++ b/bitbake/lib/toaster/orm/models.py
@@ -1287,6 +1287,14 @@ class LayerSource(object):
1287 (TYPE_BUILD, "build"), 1287 (TYPE_BUILD, "build"),
1288 ) 1288 )
1289 1289
1290 def types_dict():
1291 """ Turn the TYPES enums into a simple dictionary """
1292 dictionary = {}
1293 for key in LayerSource.__dict__:
1294 if "TYPE" in key:
1295 dictionary[key] = getattr(LayerSource, key)
1296 return dictionary
1297
1290 1298
1291class Layer(models.Model): 1299class Layer(models.Model):
1292 1300
diff --git a/bitbake/lib/toaster/tests/browser/test_layerdetails_page.py b/bitbake/lib/toaster/tests/browser/test_layerdetails_page.py
index fb1007f289..71c5c12d18 100644
--- a/bitbake/lib/toaster/tests/browser/test_layerdetails_page.py
+++ b/bitbake/lib/toaster/tests/browser/test_layerdetails_page.py
@@ -49,9 +49,6 @@ class TestLayerDetailsPage(SeleniumTestCase):
49 # project to add new custom images to 49 # project to add new custom images to
50 self.project = Project.objects.create(name='foo', release=release) 50 self.project = Project.objects.create(name='foo', release=release)
51 51
52 layer_source = LayerSource.objects.create(
53 sourcetype=LayerSource.TYPE_IMPORTED)
54
55 name = "meta-imported" 52 name = "meta-imported"
56 vcs_url = "git://example.com/meta-imported" 53 vcs_url = "git://example.com/meta-imported"
57 subdir = "/layer" 54 subdir = "/layer"
diff --git a/bitbake/lib/toaster/toastergui/api.py b/bitbake/lib/toaster/toastergui/api.py
index 112ce58914..414afce1d0 100644
--- a/bitbake/lib/toaster/toastergui/api.py
+++ b/bitbake/lib/toaster/toastergui/api.py
@@ -147,7 +147,7 @@ class XhrLayer(View):
147 layer_version = Layer_Version.objects.get( 147 layer_version = Layer_Version.objects.get(
148 id=kwargs['layerversion_id'], 148 id=kwargs['layerversion_id'],
149 project=kwargs['pid'], 149 project=kwargs['pid'],
150 layer_source__sourcetype=LayerSource.TYPE_IMPORTED) 150 layer_source=LayerSource.TYPE_IMPORTED)
151 151
152 except Layer_Version.DoesNotExist: 152 except Layer_Version.DoesNotExist:
153 return error_response("Cannot find imported layer to update") 153 return error_response("Cannot find imported layer to update")
@@ -159,8 +159,6 @@ class XhrLayer(View):
159 if "commit" in request.POST: 159 if "commit" in request.POST:
160 layer_version.commit = request.POST["commit"] 160 layer_version.commit = request.POST["commit"]
161 layer_version.branch = request.POST["commit"] 161 layer_version.branch = request.POST["commit"]
162 if "up_branch" in request.POST:
163 layer_version.up_branch_id = int(request.POST["up_branch"])
164 if "summary" in request.POST: 162 if "summary" in request.POST:
165 layer_version.layer.summary = request.POST["summary"] 163 layer_version.layer.summary = request.POST["summary"]
166 if "description" in request.POST: 164 if "description" in request.POST:
@@ -193,7 +191,7 @@ class XhrLayer(View):
193 layer_version = Layer_Version.objects.get( 191 layer_version = Layer_Version.objects.get(
194 id=kwargs['layerversion_id'], 192 id=kwargs['layerversion_id'],
195 project=kwargs['pid'], 193 project=kwargs['pid'],
196 layer_source__sourcetype=LayerSource.TYPE_IMPORTED) 194 layer_source=LayerSource.TYPE_IMPORTED)
197 except Layer_Version.DoesNotExist: 195 except Layer_Version.DoesNotExist:
198 return error_response("Cannot find imported layer to delete") 196 return error_response("Cannot find imported layer to delete")
199 197
diff --git a/bitbake/lib/toaster/toastergui/static/js/layerdetails.js b/bitbake/lib/toaster/toastergui/static/js/layerdetails.js
index 683486e53b..0d4240b354 100644
--- a/bitbake/lib/toaster/toastergui/static/js/layerdetails.js
+++ b/bitbake/lib/toaster/toastergui/static/js/layerdetails.js
@@ -366,7 +366,7 @@ function layerDetailsPageInit (ctx) {
366 if ($(this).is("dt")) { 366 if ($(this).is("dt")) {
367 var dd = $(this).next("dd"); 367 var dd = $(this).next("dd");
368 if (!dd.children("form:visible")|| !dd.find(".current-value").html()){ 368 if (!dd.children("form:visible")|| !dd.find(".current-value").html()){
369 if (ctx.layerVersion.sourceId == 3){ 369 if (ctx.layerVersion.layer_source == ctx.layerSourceTypes.TYPE_IMPORTED){
370 /* There's no current value and the layer is editable 370 /* There's no current value and the layer is editable
371 * so show the "Not set" and hide the delete icon 371 * so show the "Not set" and hide the delete icon
372 */ 372 */
diff --git a/bitbake/lib/toaster/toastergui/templates/layerdetails.html b/bitbake/lib/toaster/toastergui/templates/layerdetails.html
index 4b51d1a39c..029c93b978 100644
--- a/bitbake/lib/toaster/toastergui/templates/layerdetails.html
+++ b/bitbake/lib/toaster/toastergui/templates/layerdetails.html
@@ -36,7 +36,7 @@
36 </ul> 36 </ul>
37 37
38 {# If this is not an imported layer then hide the edit ui #} 38 {# If this is not an imported layer then hide the edit ui #}
39 {% if not layerversion.layer_source_id or layerversion.layer_source.sourcetype != layerversion.layer_source.TYPE_IMPORTED %} 39 {% if layerversion.layer_source != layer_source.TYPE_IMPORTED %}
40 <style scoped> 40 <style scoped>
41 .glyphicon-edit { 41 .glyphicon-edit {
42 display:none; 42 display:none;
@@ -69,8 +69,9 @@
69 inCurrentPrj : false, 69 inCurrentPrj : false,
70 {% endif %} 70 {% endif %}
71 layerdetailurl : "{% url 'layerdetails' project.id layerversion.id %}", 71 layerdetailurl : "{% url 'layerdetails' project.id layerversion.id %}",
72 sourceId: {{layerversion.layer_source_id|json}}, 72 layer_source: {{layerversion.layer_source|json}},
73 } 73 },
74 layerSourceTypes: {{layer_source|json}},
74 }; 75 };
75 76
76 try { 77 try {
@@ -89,7 +90,6 @@
89 {% endif %}>({{layerversion.get_vcs_reference|truncatechars:13}})</small> 90 {% endif %}>({{layerversion.get_vcs_reference|truncatechars:13}})</small>
90 </h1> 91 </h1>
91 </div> 92 </div>
92
93 <div class="row"> 93 <div class="row">
94 <!-- container for tabs --> 94 <!-- container for tabs -->
95 <div class="col-md-8 tabbable"> 95 <div class="col-md-8 tabbable">
@@ -277,15 +277,15 @@
277 <span class="glyphicon glyphicon-edit"></span> 277 <span class="glyphicon glyphicon-edit"></span>
278 <span class="glyphicon glyphicon-trash delete-current-value" data-toggle="tooltip" title="Delete"></span> 278 <span class="glyphicon glyphicon-trash delete-current-value" data-toggle="tooltip" title="Delete"></span>
279 </dd> 279 </dd>
280 {% if layerversion.layer.up_id %} 280 {% if layerversion.layer_source == layer_source.TYPE_LAYERINDEX %}
281 <dt>Layer index</dt> 281 <dt>Layer index</dt>
282 <dd> 282 <dd>
283 <a href="http://layers.openembedded.org/layerindex/branch/{{layerversion.up_branch.name}}/layer/{{layerversion.layer.name}}">layer index link</a> 283 <a href="http://layers.openembedded.org/layerindex/branch/{{layerversion.release.name}}/layer/{{layerversion.layer.name}}">Layer index {{layerversion.layer.name}}</a>
284
285 </dd> 284 </dd>
286 {% endif %} 285 {% endif %}
287 </dl> 286 </dl>
288 {% if layerversion.layer_source_id and layerversion.layer_source.sourcetype == layerversion.layer_source.TYPE_IMPORTED %} 287 {# Only show delete link for imported layers #}
288 {% if layerversion.layer_source == layer_source.TYPE_IMPORTED %}
289 <i class="icon-trash text-danger"></i> 289 <i class="icon-trash text-danger"></i>
290 <a href="#delete-layer-modal" role="button" class="text-danger" data-toggle="modal" data-target="#delete-layer-modal">Delete {{layerversion.layer.name}}</a> 290 <a href="#delete-layer-modal" role="button" class="text-danger" data-toggle="modal" data-target="#delete-layer-modal">Delete {{layerversion.layer.name}}</a>
291 {% endif %} 291 {% endif %}
diff --git a/bitbake/lib/toaster/toastergui/views.py b/bitbake/lib/toaster/toastergui/views.py
index aab6536fa0..d19815f661 100755
--- a/bitbake/lib/toaster/toastergui/views.py
+++ b/bitbake/lib/toaster/toastergui/views.py
@@ -1452,9 +1452,8 @@ if True:
1452 layers = [{"id": x.layercommit.pk, "orderid": x.pk, "name" : x.layercommit.layer.name, 1452 layers = [{"id": x.layercommit.pk, "orderid": x.pk, "name" : x.layercommit.layer.name,
1453 "vcs_url": x.layercommit.layer.vcs_url, "vcs_reference" : x.layercommit.get_vcs_reference(), 1453 "vcs_url": x.layercommit.layer.vcs_url, "vcs_reference" : x.layercommit.get_vcs_reference(),
1454 "url": x.layercommit.layer.layer_index_url, "layerdetailurl": x.layercommit.get_detailspage_url(prj.pk), 1454 "url": x.layercommit.layer.layer_index_url, "layerdetailurl": x.layercommit.get_detailspage_url(prj.pk),
1455 # This branch name is actually the release
1456 "branch" : {"name" : x.layercommit.get_vcs_reference(), 1455 "branch" : {"name" : x.layercommit.get_vcs_reference(),
1457 "layersource" : x.layercommit.up_branch.layer_source.name if x.layercommit.up_branch != None else None} 1456 "layersource" : x.layercommit.layer_source }
1458 } for x in prj.projectlayer_set.all().order_by("id")] 1457 } for x in prj.projectlayer_set.all().order_by("id")]
1459 1458
1460 context = { 1459 context = {
@@ -1670,10 +1669,7 @@ if True:
1670 1669
1671 # We need to know what release the current project is so that we 1670 # We need to know what release the current project is so that we
1672 # can set the imported layer's up_branch_id 1671 # can set the imported layer's up_branch_id
1673 prj_branch_name = Release.objects.get(pk=prj.release_id).branch_name
1674 up_branch, branch_created = Branch.objects.get_or_create(name=prj_branch_name, layer_source_id=LayerSource.TYPE_IMPORTED)
1675 1672
1676 layer_source = LayerSource.objects.get(sourcetype=LayerSource.TYPE_IMPORTED)
1677 try: 1673 try:
1678 layer, layer_created = Layer.objects.get_or_create(name=post_data['name']) 1674 layer, layer_created = Layer.objects.get_or_create(name=post_data['name'])
1679 except MultipleObjectsReturned: 1675 except MultipleObjectsReturned:
@@ -1681,7 +1677,6 @@ if True:
1681 1677
1682 if layer: 1678 if layer:
1683 if layer_created: 1679 if layer_created:
1684 layer.layer_source = layer_source
1685 layer.vcs_url = post_data['vcs_url'] 1680 layer.vcs_url = post_data['vcs_url']
1686 layer.up_date = timezone.now() 1681 layer.up_date = timezone.now()
1687 layer.save() 1682 layer.save()
@@ -1692,12 +1687,24 @@ if True:
1692 if layer.vcs_url != post_data['vcs_url']: 1687 if layer.vcs_url != post_data['vcs_url']:
1693 return HttpResponse(jsonfilter({"error": "hint-layer-exists-with-different-url" , "current_url" : layer.vcs_url, "current_id": layer.id }), content_type = "application/json") 1688 return HttpResponse(jsonfilter({"error": "hint-layer-exists-with-different-url" , "current_url" : layer.vcs_url, "current_id": layer.id }), content_type = "application/json")
1694 1689
1695 1690 layer_version, version_created = \
1696 layer_version, version_created = Layer_Version.objects.get_or_create(layer_source=layer_source, layer=layer, project=prj, up_branch_id=up_branch.id,branch=post_data['git_ref'], commit=post_data['git_ref'], dirpath=post_data['dir_path']) 1691 Layer_Version.objects.get_or_create(
1692 layer_source=LayerSource.TYPE_IMPORTED,
1693 layer=layer, project=prj,
1694 release=prj.release,
1695 branch=post_data['git_ref'],
1696 commit=post_data['git_ref'],
1697 dirpath=post_data['dir_path'])
1697 1698
1698 if layer_version: 1699 if layer_version:
1699 if not version_created: 1700 if not version_created:
1700 return HttpResponse(jsonfilter({"error": "hint-layer-version-exists", "existing_layer_version": layer_version.id }), content_type = "application/json") 1701 return HttpResponse(jsonfilter({"error":
1702 "hint-layer-version-exists",
1703 "existing_layer_version":
1704 layer_version.id }),
1705 content_type = "application/json")
1706
1707 layer_version.layer_source = LayerSource.TYPE_IMPORTED
1701 1708
1702 layer_version.up_date = timezone.now() 1709 layer_version.up_date = timezone.now()
1703 layer_version.save() 1710 layer_version.save()
@@ -2179,20 +2186,33 @@ if True:
2179 } 2186 }
2180 return render(request, template, context) 2187 return render(request, template, context)
2181 2188
2189 # TODO merge with api pseudo api here is used for deps modal
2182 @_template_renderer('layerdetails.html') 2190 @_template_renderer('layerdetails.html')
2183 def layerdetails(request, pid, layerid): 2191 def layerdetails(request, pid, layerid):
2184 project = Project.objects.get(pk=pid) 2192 project = Project.objects.get(pk=pid)
2185 layer_version = Layer_Version.objects.get(pk=layerid) 2193 layer_version = Layer_Version.objects.get(pk=layerid)
2186 2194
2187 context = {'project' : project, 2195 project_layers = ProjectLayer.objects.filter(
2188 'layerversion' : layer_version, 2196 project=project).values_list("layercommit_id",
2189 'layerdeps' : {"list": [{"id": dep.id, 2197 flat=True)
2190 "name": dep.layer.name, 2198
2191 "layerdetailurl": reverse('layerdetails', args=(pid, dep.pk)), 2199 context = {
2192 "vcs_url": dep.layer.vcs_url, 2200 'project': project,
2193 "vcs_reference": dep.get_vcs_reference()} \ 2201 'layer_source': LayerSource.types_dict(),
2194 for dep in layer_version.get_alldeps(project.id)]}, 2202 'layerversion': layer_version,
2195 'projectlayers': [player.layercommit.id for player in ProjectLayer.objects.filter(project=project)] 2203 'layerdeps': {
2204 "list": [
2205 {
2206 "id": dep.id,
2207 "name": dep.layer.name,
2208 "layerdetailurl": reverse('layerdetails',
2209 args=(pid, dep.pk)),
2210 "vcs_url": dep.layer.vcs_url,
2211 "vcs_reference": dep.get_vcs_reference()
2212 }
2213 for dep in layer_version.get_alldeps(project.id)]
2214 },
2215 'projectlayers': list(project_layers)
2196 } 2216 }
2197 2217
2198 return context 2218 return context