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:45 +0100
committerRichard Purdie <richard.purdie@linuxfoundation.org>2016-04-19 21:11:26 +0100
commita40a3e6defefd69521a417a366b8752be7e778f9 (patch)
treeaa23613673cd30831cdf8482aa03d3de97a54e7c /bitbake/lib/toaster/orm/models.py
parente65c9808e9bb85ffd2b668bade4b8a50e470d050 (diff)
downloadpoky-a40a3e6defefd69521a417a366b8752be7e778f9.tar.gz
bitbake: toaster: add build dashboard buttons to edit/create custom images
When a build is viewed in the dashboard, enable users to edit a custom image which was built during that build, and/or create a new custom image based on one of the image recipes built during the build. Add methods to the Build model to enable querying for the set of image recipes built during a build. Add buttons to the dashboard, with the "Edit custom image" button opening a basic modal for now. The "New custom image" button opens the existing new custom image modal, but is modified to show a list of images available as a base for a new custom image. Add a new function to the new custom image modal's script which enables multiple potential custom images to be shown as radio buttons in the dialog (if there is more than 1). Modify existing code to use this new function. Add a template filter which allows the queryset of recipes for a build to be available to client-side scripts, and from there be used to populate the new custom image modal. [YOCTO #9123] (Bitbake rev: 4c49ffd28e41c4597bdac34d5e54c125571a4b95) 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.py41
1 files changed, 41 insertions, 0 deletions
diff --git a/bitbake/lib/toaster/orm/models.py b/bitbake/lib/toaster/orm/models.py
index f0a8786640..75e6ea3996 100644
--- a/bitbake/lib/toaster/orm/models.py
+++ b/bitbake/lib/toaster/orm/models.py
@@ -490,6 +490,47 @@ class Build(models.Model):
490 tgts = Target.objects.filter(build_id = self.id).order_by( 'target' ); 490 tgts = Target.objects.filter(build_id = self.id).order_by( 'target' );
491 return( tgts ); 491 return( tgts );
492 492
493 def get_recipes(self):
494 """
495 Get the recipes related to this build;
496 note that the related layer versions and layers are also prefetched
497 by this query, as this queryset can be sorted by these objects in the
498 build recipes view; prefetching them here removes the need
499 for another query in that view
500 """
501 layer_versions = Layer_Version.objects.filter(build=self)
502 criteria = Q(layer_version__id__in=layer_versions)
503 return Recipe.objects.filter(criteria) \
504 .select_related('layer_version', 'layer_version__layer')
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):
518 """
519 Returns a queryset of image recipes related to this build, sorted
520 by name
521 """
522 criteria = Q(is_image=True)
523 return self.get_recipes().filter(criteria).order_by('name')
524
525 def get_custom_image_recipes(self):
526 """
527 Returns a queryset of custom image recipes related to this build,
528 sorted by name
529 """
530 custom_image_recipe_names = self.get_custom_image_recipe_names()
531 criteria = Q(is_image=True) & Q(name__in=custom_image_recipe_names)
532 return self.get_recipes().filter(criteria).order_by('name')
533
493 def get_outcome_text(self): 534 def get_outcome_text(self):
494 return Build.BUILD_OUTCOME[int(self.outcome)][1] 535 return Build.BUILD_OUTCOME[int(self.outcome)][1]
495 536