summaryrefslogtreecommitdiffstats
path: root/bitbake/lib/toaster/orm/models.py
diff options
context:
space:
mode:
authorElliot Smith <elliot.smith@intel.com>2016-04-19 17:28:46 +0100
committerRichard Purdie <richard.purdie@linuxfoundation.org>2016-04-19 21:11:26 +0100
commit1cf8f215b3543ce0f39ebd3321d58cfb518f1c1f (patch)
treeac2ec1be24db0eb3f845d53cfa7ce6c18c36ab70 /bitbake/lib/toaster/orm/models.py
parenta40a3e6defefd69521a417a366b8752be7e778f9 (diff)
downloadpoky-1cf8f215b3543ce0f39ebd3321d58cfb518f1c1f.tar.gz
bitbake: toaster: add modal to select custom image for editing
Add functionality to the placeholder button on the build dashboard to open a modal dialog displaying editable custom images, in cases where multiple custom images were built by the build. Where there is only one editable custom image, go direct to its edit page. The images shown in the modal are custom recipes for the project which were built during the build shown in the dashboard. This also affects the new custom image dialog, as that also has to show custom image recipes as well as image recipes built during the build. Modify the API on the Build object to support both. Also modify and rename the queryset_to_list template filter so that it can deal with lists as well as querysets, as the new custom image modal has to show a list of image recipes which is an amalgam of two querysets. [YOCTO #9123] (Bitbake rev: 8c2aea3fa8e1071de60390e86e2536904fa9b7c0) Signed-off-by: Elliot Smith <elliot.smith@intel.com> Signed-off-by: Michael Wood <michael.g.wood@intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake/lib/toaster/orm/models.py')
-rw-r--r--bitbake/lib/toaster/orm/models.py45
1 files changed, 26 insertions, 19 deletions
diff --git a/bitbake/lib/toaster/orm/models.py b/bitbake/lib/toaster/orm/models.py
index 75e6ea3996..0b83b991b9 100644
--- a/bitbake/lib/toaster/orm/models.py
+++ b/bitbake/lib/toaster/orm/models.py
@@ -503,33 +503,37 @@ class Build(models.Model):
503 return Recipe.objects.filter(criteria) \ 503 return Recipe.objects.filter(criteria) \
504 .select_related('layer_version', 'layer_version__layer') 504 .select_related('layer_version', 'layer_version__layer')
505 505
506 def get_custom_image_recipe_names(self):
507 """
508 Get the names of custom image recipes for this build's project
509 as a list; this is used to screen out custom image recipes from the
510 recipes for the build by name, and to distinguish image recipes from
511 custom image recipes
512 """
513 custom_image_recipes = \
514 CustomImageRecipe.objects.filter(project=self.project)
515 return custom_image_recipes.values_list('name', flat=True)
516
517 def get_image_recipes(self): 506 def get_image_recipes(self):
518 """ 507 """
519 Returns a queryset of image recipes related to this build, sorted 508 Returns a list of image Recipes (custom and built-in) related to this
520 by name 509 build, sorted by name; note that this has to be done in two steps, as
510 there's no way to get all the custom image recipes and image recipes
511 in one query
521 """ 512 """
522 criteria = Q(is_image=True) 513 custom_image_recipes = self.get_custom_image_recipes()
523 return self.get_recipes().filter(criteria).order_by('name') 514 custom_image_recipe_names = custom_image_recipes.values_list('name', flat=True)
515
516 not_custom_image_recipes = ~Q(name__in=custom_image_recipe_names) & \
517 Q(is_image=True)
518
519 built_image_recipes = self.get_recipes().filter(not_custom_image_recipes)
520
521 # append to the custom image recipes and sort
522 customisable_image_recipes = list(
523 itertools.chain(custom_image_recipes, built_image_recipes)
524 )
525
526 return sorted(customisable_image_recipes, key=lambda recipe: recipe.name)
524 527
525 def get_custom_image_recipes(self): 528 def get_custom_image_recipes(self):
526 """ 529 """
527 Returns a queryset of custom image recipes related to this build, 530 Returns a queryset of CustomImageRecipes related to this build,
528 sorted by name 531 sorted by name
529 """ 532 """
530 custom_image_recipe_names = self.get_custom_image_recipe_names() 533 built_recipe_names = self.get_recipes().values_list('name', flat=True)
531 criteria = Q(is_image=True) & Q(name__in=custom_image_recipe_names) 534 criteria = Q(name__in=built_recipe_names) & Q(project=self.project)
532 return self.get_recipes().filter(criteria).order_by('name') 535 queryset = CustomImageRecipe.objects.filter(criteria).order_by('name')
536 return queryset
533 537
534 def get_outcome_text(self): 538 def get_outcome_text(self):
535 return Build.BUILD_OUTCOME[int(self.outcome)][1] 539 return Build.BUILD_OUTCOME[int(self.outcome)][1]
@@ -1380,6 +1384,9 @@ class Layer(models.Model):
1380 1384
1381# LayerCommit class is synced with layerindex.LayerBranch 1385# LayerCommit class is synced with layerindex.LayerBranch
1382class Layer_Version(models.Model): 1386class Layer_Version(models.Model):
1387 """
1388 A Layer_Version either belongs to a single project or no project
1389 """
1383 search_allowed_fields = ["layer__name", "layer__summary", "layer__description", "layer__vcs_url", "dirpath", "up_branch__name", "commit", "branch"] 1390 search_allowed_fields = ["layer__name", "layer__summary", "layer__description", "layer__vcs_url", "dirpath", "up_branch__name", "commit", "branch"]
1384 build = models.ForeignKey(Build, related_name='layer_version_build', default = None, null = True) 1391 build = models.ForeignKey(Build, related_name='layer_version_build', default = None, null = True)
1385 layer = models.ForeignKey(Layer, related_name='layer_version_layer') 1392 layer = models.ForeignKey(Layer, related_name='layer_version_layer')