Return-Path: Received: by yocto-www.yoctoproject.org (Postfix, from userid 118) id 55196E00E74; Thu, 7 Jul 2016 10:22:13 -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.41 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-f41.google.com (mail-wm0-f41.google.com [74.125.82.41]) by yocto-www.yoctoproject.org (Postfix) with ESMTP id 1E595E00E57 for ; Thu, 7 Jul 2016 10:22:08 -0700 (PDT) Received: by mail-wm0-f41.google.com with SMTP id z126so156942413wme.0 for ; Thu, 07 Jul 2016 10:22:08 -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=bK8nMVvAgpyCleyYStEbQOiL6sY669nPBifa6tCGOZk=; b=1IyOSNgcY9WGgiJ3CTsixXYG4IrushcC3U7Y7UvVvixbTqdDt+35RB55bWlypxZmwz 6eBThyu7FUmdo8sAtPEZT5jGcaclocNBFcsDZGnQYqdAvQk6Ozk6tXjnPgVNJ70wrvdf xPZVQeQacUJGnz2Jb1eBW12uo5D0eM9LLsP0sCh63Bqie/YIMDHFc5+Lxrc8/JnGdE/K X4nOdQo6962aHXPFFZINrslQil/ubd29phdBl5oS+ZrMjw9sXVgTX8o0QcCSrvMx2K/P 1G2c1D1fAfiBNFVYpcltI3LBgH7VRrqGjdeLSAFA721IUBDrXyS2L0gTBTULs0Gq+tC6 Rdvw== 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=bK8nMVvAgpyCleyYStEbQOiL6sY669nPBifa6tCGOZk=; b=Q7cZEPCFGnj27+Y9NJfsNDK8CFWWaHOdlj5+wNosGwWYbSalCXScDw1mfqRDApmE+p k446R3BCyPdNqxgGNV3X9OeS8SvxTGjDMyQYY7HoJRcYjddQh1x5YlmFc2QsBAhGiKBN 9v+BN5IcRv83jOVspjASAZfAAxIT6VjcyYFr2PFEGAAModT5rBgBDKK7Djun3anfP7jO zGW2Mg2Y8Qo2tacQ0qJTYnYslrzt+e/THH//1TJXFiQRu6m3FkRoft0+EqI5FOta2IZC 4QAxj2FhncyyvxwIJVAc1D71ZCq0Kvbpwk7tNQ7hJ8e9xuuI3fsBjzVyEQ0XAti5quL9 6XKw== X-Gm-Message-State: ALyK8tIEXnU3od+ZhD/KeGLNQFNVwbAh58OAfrWoatiKDm2yeMe5FCnsvn5OnjXnHVxoo/JQ X-Received: by 10.28.0.73 with SMTP id 70mr3826788wma.64.1467912127747; Thu, 07 Jul 2016 10:22:07 -0700 (PDT) Received: from localhost.localdomain (host86-169-85-169.range86-169.btcentralplus.com. [86.169.85.169]) by smtp.gmail.com with ESMTPSA id e69sm2059408wma.2.2016.07.07.10.22.05 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 07 Jul 2016 10:22:07 -0700 (PDT) From: Michael Wood To: toaster@yoctoproject.org Date: Thu, 7 Jul 2016 18:21:44 +0100 Message-Id: <1467912108-24659-6-git-send-email-michael.g.wood@intel.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1467912108-24659-1-git-send-email-michael.g.wood@intel.com> References: <1467912108-24659-1-git-send-email-michael.g.wood@intel.com> Subject: [PATCH v2 5/9] 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: Thu, 07 Jul 2016 17:22:13 -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 8fe4c20..cdcd7a7 100644 --- a/bitbake/lib/toaster/orm/models.py +++ b/bitbake/lib/toaster/orm/models.py @@ -1132,6 +1132,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 %}