diff options
author | Michael Wood <michael.g.wood@intel.com> | 2015-11-05 12:30:40 +0000 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2016-02-10 13:29:18 +0000 |
commit | 4e8a0aa66e15de24895b2c662b80504843f72107 (patch) | |
tree | 330cfbe97a4413a560a976ba9d4ac786c2f5f592 | |
parent | 66b5608ffec0934efdb7c32aed22ced23cc5f40e (diff) | |
download | poky-4e8a0aa66e15de24895b2c662b80504843f72107.tar.gz |
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>
-rwxr-xr-x | bitbake/lib/toaster/toastergui/views.py | 27 |
1 files changed, 13 insertions, 14 deletions
diff --git a/bitbake/lib/toaster/toastergui/views.py b/bitbake/lib/toaster/toastergui/views.py index f6f1a54597..49918089d2 100755 --- a/bitbake/lib/toaster/toastergui/views.py +++ b/bitbake/lib/toaster/toastergui/views.py | |||
@@ -2444,20 +2444,23 @@ if True: | |||
2444 | or | 2444 | or |
2445 | {"error": <error message>} | 2445 | {"error": <error message>} |
2446 | """ | 2446 | """ |
2447 | objects = CustomImageRecipe.objects.filter(id=recipe_id) | 2447 | try: |
2448 | if not objects: | 2448 | custom_recipe = CustomImageRecipe.objects.get(id=recipe_id) |
2449 | except CustomImageRecipe.DoesNotExist: | ||
2449 | return {"error": "Custom recipe with id=%s " | 2450 | return {"error": "Custom recipe with id=%s " |
2450 | "not found" % recipe_id} | 2451 | "not found" % recipe_id} |
2452 | |||
2451 | if request.method == 'GET': | 2453 | if request.method == 'GET': |
2452 | values = CustomImageRecipe.objects.filter(id=recipe_id).values() | 2454 | info = {"id" : custom_recipe.id, |
2453 | if values: | 2455 | "name" : custom_recipe.name, |
2454 | return {"error": "ok", "info": values[0]} | 2456 | "base_recipe_id": custom_recipe.base_recipe.id, |
2455 | else: | 2457 | "project_id": custom_recipe.project.id, |
2456 | return {"error": "Custom recipe with id=%s " | 2458 | } |
2457 | "not found" % recipe_id} | 2459 | |
2458 | return {"error": "ok", "info": objects.values()[0]} | 2460 | return {"error": "ok", "info": info} |
2461 | |||
2459 | elif request.method == 'DELETE': | 2462 | elif request.method == 'DELETE': |
2460 | objects.delete() | 2463 | custom_recipe.delete() |
2461 | return {"error": "ok"} | 2464 | return {"error": "ok"} |
2462 | else: | 2465 | else: |
2463 | return {"error": "Method %s is not supported" % request.method} | 2466 | return {"error": "Method %s is not supported" % request.method} |
@@ -2533,10 +2536,6 @@ if True: | |||
2533 | 2536 | ||
2534 | dependencies = filter(in_image, dependencies['runtime_deps']) | 2537 | dependencies = filter(in_image, dependencies['runtime_deps']) |
2535 | return {"error": "ok", | 2538 | return {"error": "ok", |
2536 | "new_package" : {"id": package.pk, | ||
2537 | "url": reverse('xhr_customrecipe_packages', | ||
2538 | args=(recipe.pk, package.pk)) | ||
2539 | }, | ||
2540 | "dependencies_needed" : dependencies, | 2539 | "dependencies_needed" : dependencies, |
2541 | } | 2540 | } |
2542 | 2541 | ||