1
0
mirror of https://git.yoctoproject.org/poky synced 2026-06-01 13:09:50 +00:00

bitbake: toaster: views xhr_customrecipe_packages clean up API

- Fix generic variable names such as "object" and "values" when not
  needed.
- Use try catch instead of a queryset filter to return the custom recipe
  object
- Be explicit about the fields returned for the custom recipe info field
- Remove redundant new_package field

(Bitbake rev: a1a69903a94264377666730b1eb4599e6f3b4398)

Signed-off-by: Michael Wood <michael.g.wood@intel.com>
Signed-off-by: brian avery <avery.brian@gmail.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
This commit is contained in:
Michael Wood
2015-11-05 12:30:40 +00:00
committed by Richard Purdie
parent 66b5608ffe
commit 4e8a0aa66e
+13 -14
View File
@@ -2444,20 +2444,23 @@ if True:
or or
{"error": <error message>} {"error": <error message>}
""" """
objects = CustomImageRecipe.objects.filter(id=recipe_id) try:
if not objects: custom_recipe = CustomImageRecipe.objects.get(id=recipe_id)
except CustomImageRecipe.DoesNotExist:
return {"error": "Custom recipe with id=%s " return {"error": "Custom recipe with id=%s "
"not found" % recipe_id} "not found" % recipe_id}
if request.method == 'GET': if request.method == 'GET':
values = CustomImageRecipe.objects.filter(id=recipe_id).values() info = {"id" : custom_recipe.id,
if values: "name" : custom_recipe.name,
return {"error": "ok", "info": values[0]} "base_recipe_id": custom_recipe.base_recipe.id,
else: "project_id": custom_recipe.project.id,
return {"error": "Custom recipe with id=%s " }
"not found" % recipe_id}
return {"error": "ok", "info": objects.values()[0]} return {"error": "ok", "info": info}
elif request.method == 'DELETE': elif request.method == 'DELETE':
objects.delete() custom_recipe.delete()
return {"error": "ok"} return {"error": "ok"}
else: else:
return {"error": "Method %s is not supported" % request.method} return {"error": "Method %s is not supported" % request.method}
@@ -2533,10 +2536,6 @@ if True:
dependencies = filter(in_image, dependencies['runtime_deps']) dependencies = filter(in_image, dependencies['runtime_deps'])
return {"error": "ok", return {"error": "ok",
"new_package" : {"id": package.pk,
"url": reverse('xhr_customrecipe_packages',
args=(recipe.pk, package.pk))
},
"dependencies_needed" : dependencies, "dependencies_needed" : dependencies,
} }