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
1 changed files with 13 additions and 14 deletions

View File

@ -2444,20 +2444,23 @@ if True:
or
{"error": <error message>}
"""
objects = CustomImageRecipe.objects.filter(id=recipe_id)
if not objects:
try:
custom_recipe = CustomImageRecipe.objects.get(id=recipe_id)
except CustomImageRecipe.DoesNotExist:
return {"error": "Custom recipe with id=%s "
"not found" % recipe_id}
if request.method == 'GET':
values = CustomImageRecipe.objects.filter(id=recipe_id).values()
if values:
return {"error": "ok", "info": values[0]}
else:
return {"error": "Custom recipe with id=%s "
"not found" % recipe_id}
return {"error": "ok", "info": objects.values()[0]}
info = {"id" : custom_recipe.id,
"name" : custom_recipe.name,
"base_recipe_id": custom_recipe.base_recipe.id,
"project_id": custom_recipe.project.id,
}
return {"error": "ok", "info": info}
elif request.method == 'DELETE':
objects.delete()
custom_recipe.delete()
return {"error": "ok"}
else:
return {"error": "Method %s is not supported" % request.method}
@ -2533,10 +2536,6 @@ if True:
dependencies = filter(in_image, dependencies['runtime_deps'])
return {"error": "ok",
"new_package" : {"id": package.pk,
"url": reverse('xhr_customrecipe_packages',
args=(recipe.pk, package.pk))
},
"dependencies_needed" : dependencies,
}