Return-Path: Received: from goldenrod.cherry.relay.mailchannels.net (goldenrod.cherry.relay.mailchannels.net [23.83.223.74]) by mail.openembedded.org (Postfix) with ESMTP id E2FE9731C6 for ; Thu, 21 Jul 2016 13:44:33 +0000 (UTC) X-Sender-Id: wwwh|x-authuser|elliot@townx.org Received: from relay.mailchannels.net (localhost [127.0.0.1]) by relay.mailchannels.net (Postfix) with ESMTP id 1ACFD1BCBEA; Thu, 21 Jul 2016 13:44:29 +0000 (UTC) Received: from uscentral428.accountservergroup.com (ip-10-107-69-155.us-west-2.compute.internal [10.107.69.155]) by relay.mailchannels.net (Postfix) with ESMTPA id 490E71BC844; Thu, 21 Jul 2016 13:44:28 +0000 (UTC) X-Sender-Id: wwwh|x-authuser|elliot@townx.org Received: from uscentral428.accountservergroup.com ([TEMPUNAVAIL]. [10.135.9.54]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384) by 0.0.0.0:2500 (trex/5.7.1); Thu, 21 Jul 2016 13:44:29 +0000 X-MC-Relay: Good X-MailChannels-SenderId: wwwh|x-authuser|elliot@townx.org X-MailChannels-Auth-Id: wwwh X-MC-Loop-Signature: 1469108668695:922830129 X-MC-Ingress-Time: 1469108668695 Received: from [176.249.240.35] (port=56888 helo=localhost.localdomain) by uscentral428.accountservergroup.com with esmtpa (Exim 4.87) (envelope-from ) id 1bQEH3-0002ZY-EZ; Thu, 21 Jul 2016 09:44:25 -0400 From: Elliot Smith To: bitbake-devel@lists.openembedded.org Date: Thu, 21 Jul 2016 14:43:27 +0100 Message-Id: <1469108612-12433-5-git-send-email-elliot.smith@intel.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1469108612-12433-1-git-send-email-elliot.smith@intel.com> References: <1469108612-12433-1-git-send-email-elliot.smith@intel.com> X-AuthUser: elliot@townx.org Subject: [PATCH][v2 05/10] toaster: Replace references to LayerSource models X-BeenThere: bitbake-devel@lists.openembedded.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: Patches and discussion that advance bitbake development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 21 Jul 2016 13:44:38 -0000 From: Michael Wood Replace references to the now deprecated layersource models across Toaster with the new enums for layer source types. Signed-off-by: Michael Wood Signed-off-by: Elliot Smith --- bitbake/lib/toaster/bldcontrol/tests.py | 19 -------- bitbake/lib/toaster/orm/models.py | 8 ++++ .../tests/browser/test_layerdetails_page.py | 3 -- bitbake/lib/toaster/toastergui/api.py | 6 +-- .../toaster/toastergui/static/js/layerdetails.js | 2 +- .../toaster/toastergui/templates/layerdetails.html | 16 +++---- bitbake/lib/toaster/toastergui/views.py | 56 +++++++++++++++------- 7 files changed, 57 insertions(+), 53 deletions(-) diff --git a/bitbake/lib/toaster/bldcontrol/tests.py b/bitbake/lib/toaster/bldcontrol/tests.py index 32985c3..475ac0a 100644 --- a/bitbake/lib/toaster/bldcontrol/tests.py +++ b/bitbake/lib/toaster/bldcontrol/tests.py @@ -139,22 +139,3 @@ class RunBuildsCommandTests(TestCase): self.assertTrue(br.state == BuildRequest.REQ_INPROGRESS, "Request is not updated") # no more selections possible here self.assertRaises(IndexError, command._selectBuildRequest) - - -class UtilityTests(TestCase): - def test_reduce_path(self): - from bldcontrol.management.commands.loadconf import _reduce_canon_path, _get_id_for_sourcetype - - self.assertTrue( _reduce_canon_path("/") == "/") - self.assertTrue( _reduce_canon_path("/home/..") == "/") - self.assertTrue( _reduce_canon_path("/home/../ana") == "/ana") - self.assertTrue( _reduce_canon_path("/home/../ana/..") == "/") - self.assertTrue( _reduce_canon_path("/home/ana/mihai/../maria") == "/home/ana/maria") - - def test_get_id_for_sorucetype(self): - from bldcontrol.management.commands.loadconf import _reduce_canon_path, _get_id_for_sourcetype - self.assertTrue( _get_id_for_sourcetype("layerindex") == 1) - self.assertTrue( _get_id_for_sourcetype("local") == 0) - self.assertTrue( _get_id_for_sourcetype("imported") == 2) - with self.assertRaises(Exception): - _get_id_for_sourcetype("unknown") diff --git a/bitbake/lib/toaster/orm/models.py b/bitbake/lib/toaster/orm/models.py index 1daec9c..34ea28c 100644 --- a/bitbake/lib/toaster/orm/models.py +++ b/bitbake/lib/toaster/orm/models.py @@ -1287,6 +1287,14 @@ class LayerSource(object): (TYPE_BUILD, "build"), ) + def types_dict(): + """ Turn the TYPES enums into a simple dictionary """ + dictionary = {} + for key in LayerSource.__dict__: + if "TYPE" in key: + dictionary[key] = getattr(LayerSource, key) + return dictionary + class Layer(models.Model): diff --git a/bitbake/lib/toaster/tests/browser/test_layerdetails_page.py b/bitbake/lib/toaster/tests/browser/test_layerdetails_page.py index fb1007f..71c5c12 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): # project to add new custom images to self.project = Project.objects.create(name='foo', release=release) - layer_source = LayerSource.objects.create( - sourcetype=LayerSource.TYPE_IMPORTED) - name = "meta-imported" vcs_url = "git://example.com/meta-imported" subdir = "/layer" diff --git a/bitbake/lib/toaster/toastergui/api.py b/bitbake/lib/toaster/toastergui/api.py index 112ce58..414afce 100644 --- a/bitbake/lib/toaster/toastergui/api.py +++ b/bitbake/lib/toaster/toastergui/api.py @@ -147,7 +147,7 @@ class XhrLayer(View): layer_version = Layer_Version.objects.get( id=kwargs['layerversion_id'], project=kwargs['pid'], - layer_source__sourcetype=LayerSource.TYPE_IMPORTED) + layer_source=LayerSource.TYPE_IMPORTED) except Layer_Version.DoesNotExist: return error_response("Cannot find imported layer to update") @@ -159,8 +159,6 @@ class XhrLayer(View): if "commit" in request.POST: layer_version.commit = request.POST["commit"] layer_version.branch = request.POST["commit"] - if "up_branch" in request.POST: - layer_version.up_branch_id = int(request.POST["up_branch"]) if "summary" in request.POST: layer_version.layer.summary = request.POST["summary"] if "description" in request.POST: @@ -193,7 +191,7 @@ class XhrLayer(View): layer_version = Layer_Version.objects.get( id=kwargs['layerversion_id'], project=kwargs['pid'], - layer_source__sourcetype=LayerSource.TYPE_IMPORTED) + layer_source=LayerSource.TYPE_IMPORTED) except Layer_Version.DoesNotExist: return error_response("Cannot find imported layer to delete") diff --git a/bitbake/lib/toaster/toastergui/static/js/layerdetails.js b/bitbake/lib/toaster/toastergui/static/js/layerdetails.js index 683486e..0d4240b 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) { if ($(this).is("dt")) { var dd = $(this).next("dd"); if (!dd.children("form:visible")|| !dd.find(".current-value").html()){ - if (ctx.layerVersion.sourceId == 3){ + if (ctx.layerVersion.layer_source == ctx.layerSourceTypes.TYPE_IMPORTED){ /* There's no current value and the layer is editable * so show the "Not set" and hide the delete icon */ diff --git a/bitbake/lib/toaster/toastergui/templates/layerdetails.html b/bitbake/lib/toaster/toastergui/templates/layerdetails.html index 4b51d1a..029c93b 100644 --- a/bitbake/lib/toaster/toastergui/templates/layerdetails.html +++ b/bitbake/lib/toaster/toastergui/templates/layerdetails.html @@ -36,7 +36,7 @@ {# If this is not an imported layer then hide the edit ui #} - {% if not layerversion.layer_source_id or layerversion.layer_source.sourcetype != layerversion.layer_source.TYPE_IMPORTED %} + {% if layerversion.layer_source != layer_source.TYPE_IMPORTED %}