Return-Path: Received: by yocto-www.yoctoproject.org (Postfix, from userid 118) id 1EC64E009DA; Wed, 20 Jul 2016 06:48:26 -0700 (PDT) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on yocto-www.yoctoproject.org X-Spam-Level: X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_LOW autolearn=ham version=3.3.1 X-Spam-HAM-Report: * -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low * trust * [74.125.82.48 listed in list.dnswl.org] * -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% * [score: 0.0000] * 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily * valid * -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature Received: from mail-wm0-f48.google.com (mail-wm0-f48.google.com [74.125.82.48]) by yocto-www.yoctoproject.org (Postfix) with ESMTP id CFAF7E009BF for ; Wed, 20 Jul 2016 06:48:22 -0700 (PDT) Received: by mail-wm0-f48.google.com with SMTP id o80so70036541wme.1 for ; Wed, 20 Jul 2016 06:48:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=intel-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=tfRDzcD1jJqBytMQC38CnY4rqQMEw9DZ5+t1YEw/Rlo=; b=Bjxzbcsrx20hVZemzl4cK84sZso1JWlthVJJ7i+JxbPQwc/duQnYjQsDr3GulmWxxN jXWZ9Tc+jJCH/zyXBwfjfuM85kBGK0PLi+YLzE/U/p2MPeZ7mcTc8VfqoSrtFI7gRWxM rRus416nXeZlng1UULI43NOirhEFS8UAa/TAr+53yJ4BmD+JR4zlmg78TmZjp0G82GGR 0fX9lKPHuZVL1QTSxhHq6zOzDMl/Skqo/GseKjBYrFgd1VKMCufuVXCKV/RolKKsquyz JNN1DgiTKfxskutBicg4mjC6j0OrgvNjEwzzxf4SBtVkKL43OIl4f4SNrfu0PYwrk/2q veIQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=tfRDzcD1jJqBytMQC38CnY4rqQMEw9DZ5+t1YEw/Rlo=; b=hd7vcqlNSdVPezBgEh8asd0lxBy3YZJprkgoCfOA40SgOhjiezfoIhm1ze65M9oCXz QUpFbBlbvkt9gOTMp9uZW/2J2lt0ishRxdQwm8/N1X/CBSswuJ2gbmefL27rsxD8LJ7I 5Y8bRt4G4JJ6jGL+eSqOyTwljWUU+oJNITzctHQmRPHwoNpvPV7aoDKdAodBHyImPuZF Y8/+uOQl6KgNbEr3lVifUS6eQWfnyhE0vSaV8+KHOI7WeiiCsI6fa9GhbB+wgYDUoVXp bAn1GiRs5Cowx32ioBplvZk8zfei+dzh406qUa08+C+r4ZmONkIgiw3w/ISqv11HuRFN yc2g== X-Gm-Message-State: ALyK8tLpxomH+YURaPinAb+VECnxXeGnhu3OCOsLL5+qSltKakTiSfMubMv5gU1yqkcfIsm8 X-Received: by 10.28.226.130 with SMTP id z124mr12021725wmg.82.1469022501680; Wed, 20 Jul 2016 06:48:21 -0700 (PDT) Received: from localhost.localdomain (host109-153-40-30.range109-153.btcentralplus.com. [109.153.40.30]) by smtp.gmail.com with ESMTPSA id d64sm5206662wmc.22.2016.07.20.06.48.20 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 20 Jul 2016 06:48:21 -0700 (PDT) From: Michael Wood To: toaster@yoctoproject.org Date: Wed, 20 Jul 2016 14:48:07 +0100 Message-Id: <1469022492-19823-6-git-send-email-michael.g.wood@intel.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1469022492-19823-1-git-send-email-michael.g.wood@intel.com> References: <1469022492-19823-1-git-send-email-michael.g.wood@intel.com> Subject: [PATCH v3 05/10] toaster: Replace references to LayerSource models X-BeenThere: toaster@yoctoproject.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: Web based interface for BitBake List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 20 Jul 2016 13:48:26 -0000 Replace references to the now deprecated layersource models across Toaster with the new enums for layer source types. Signed-off-by: Michael Wood --- 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 %}