1
0
mirror of https://git.yoctoproject.org/poky synced 2026-05-30 12:29:55 +00:00

bitbake: toaster: layerdetails api Fix saving of git revision of a layer

Update, clean up and move the api for updating a layerversion from the
views to api. Also update the layerdetails page to include the
layerversion id in the url getter.

[YOCTO #8952]

(Bitbake rev: 20f4e23bc86290f0a42881a7cac44c41eafa86fc)

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>
This commit is contained in:
Michael Wood
2016-07-06 18:22:36 +01:00
committed by Richard Purdie
parent 903c3c2ef8
commit 36dec688c7
4 changed files with 103 additions and 46 deletions
-43
View File
@@ -1739,49 +1739,6 @@ if True:
return HttpResponse(jsonfilter(json_response), content_type = "application/json")
def xhr_updatelayer(request):
def error_response(error):
return HttpResponse(jsonfilter({"error": error}), content_type = "application/json")
if "layer_version_id" not in request.POST:
return error_response("Please specify a layer version id")
try:
layer_version_id = request.POST["layer_version_id"]
layer_version = Layer_Version.objects.get(id=layer_version_id)
except Layer_Version.DoesNotExist:
return error_response("Cannot find layer to update")
if "vcs_url" in request.POST:
layer_version.layer.vcs_url = request.POST["vcs_url"]
if "dirpath" in request.POST:
layer_version.dirpath = request.POST["dirpath"]
if "commit" in request.POST:
layer_version.commit = request.POST["commit"]
if "up_branch" in request.POST:
layer_version.up_branch_id = int(request.POST["up_branch"])
if "add_dep" in request.POST:
lvd = LayerVersionDependency(layer_version=layer_version, depends_on_id=request.POST["add_dep"])
lvd.save()
if "rm_dep" in request.POST:
rm_dep = LayerVersionDependency.objects.get(layer_version=layer_version, depends_on_id=request.POST["rm_dep"])
rm_dep.delete()
if "summary" in request.POST:
layer_version.layer.summary = request.POST["summary"]
if "description" in request.POST:
layer_version.layer.description = request.POST["description"]
try:
layer_version.layer.save()
layer_version.save()
except Exception as e:
return error_response("Could not update layer version entry: %s" % e)
return HttpResponse(jsonfilter({"error": "ok",}), content_type = "application/json")
@xhr_response
def xhr_customrecipe(request):