summaryrefslogtreecommitdiffstats
path: root/bitbake/lib/toaster/toastergui/views.py
diff options
context:
space:
mode:
Diffstat (limited to 'bitbake/lib/toaster/toastergui/views.py')
-rwxr-xr-xbitbake/lib/toaster/toastergui/views.py33
1 files changed, 18 insertions, 15 deletions
diff --git a/bitbake/lib/toaster/toastergui/views.py b/bitbake/lib/toaster/toastergui/views.py
index a11c9da5f5..9744f4efaf 100755
--- a/bitbake/lib/toaster/toastergui/views.py
+++ b/bitbake/lib/toaster/toastergui/views.py
@@ -2409,21 +2409,24 @@ if True:
2409 if re.search(r'[^a-z|0-9|-]', request.POST["name"]): 2409 if re.search(r'[^a-z|0-9|-]', request.POST["name"]):
2410 return {"error": "invalid-name"} 2410 return {"error": "invalid-name"}
2411 2411
2412 # Are there any recipes with the name already? 2412 custom_images = CustomImageRecipe.objects.all()
2413 for existing_recipe in Recipe.objects.filter( 2413
2414 name=request.POST["name"]): 2414 # Are there any recipes with this name already in our project?
2415 try: 2415 existing_image_recipes_in_project = custom_images.filter(
2416 ci = CustomImageRecipe.objects.get(pk=existing_recipe.pk) 2416 name=request.POST["name"], project=params["project"])
2417 if ci.project == params["project"]: 2417
2418 return {"error": "already-exists" } 2418 if existing_image_recipes_in_project.count() > 0:
2419 else: 2419 return {"error": "image-already-exists"}
2420 # It is a CustomImageRecipe but not in our project 2420
2421 # this is fine so 2421 # Are there any recipes with this name which aren't custom
2422 continue 2422 # image recipes?
2423 except: 2423 custom_image_ids = custom_images.values_list('id', flat=True)
2424 # It isn't a CustomImageRecipe so is a recipe from 2424 existing_non_image_recipes = Recipe.objects.filter(
2425 # another source. 2425 Q(name=request.POST["name"]) & ~Q(pk__in=custom_image_ids)
2426 return {"error": "already-exists" } 2426 )
2427
2428 if existing_non_image_recipes.count() > 0:
2429 return {"error": "recipe-already-exists"}
2427 2430
2428 # create layer 'Custom layer' and verion if needed 2431 # create layer 'Custom layer' and verion if needed
2429 layer = Layer.objects.get_or_create( 2432 layer = Layer.objects.get_or_create(