aboutsummaryrefslogtreecommitdiffstats
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)
downloadopenembedded-core-contrib-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):
return Recipe.objects.filter(criteria) \
.select_related('layer_version', 'layer_version__layer')
- def get_custom_image_recipe_names(self):
- """
- Get the names of custom image recipes for this build's project
- as a list; this is used to screen out custom image recipes from the
- recipes for the build by name, and to distinguish image recipes from
- custom image recipes
- """
- custom_image_recipes = \
- CustomImageRecipe.objects.filter(project=self.project)
- return custom_image_recipes.values_list('name', flat=True)
-
def get_image_recipes(self):
"""
- Returns a queryset of image recipes related to this build, sorted
- by name
+ Returns a list of image Recipes (custom and built-in) related to this
+ build, sorted by name; note that this has to be done in two steps, as
+ there's no way to get all the custom image recipes and image recipes
+ in one query
"""
- criteria = Q(is_image=True)
- return self.get_recipes().filter(criteria).order_by('name')
+ custom_image_recipes = self.get_custom_image_recipes()
+ custom_image_recipe_names = custom_image_recipes.values_list('name', flat=True)
+
+ not_custom_image_recipes = ~Q(name__in=custom_image_recipe_names) & \
+ Q(is_image=True)
+
+ built_image_recipes = self.get_recipes().filter(not_custom_image_recipes)
+
+ # append to the custom image recipes and sort
+ customisable_image_recipes = list(
+ itertools.chain(custom_image_recipes, built_image_recipes)
+ )
+
+ return sorted(customisable_image_recipes, key=lambda recipe: recipe.name)
def get_custom_image_recipes(self):
"""
- Returns a queryset of custom image recipes related to this build,
+ Returns a queryset of CustomImageRecipes related to this build,
sorted by name
"""
- custom_image_recipe_names = self.get_custom_image_recipe_names()
- criteria = Q(is_image=True) & Q(name__in=custom_image_recipe_names)
- return self.get_recipes().filter(criteria).order_by('name')
+ built_recipe_names = self.get_recipes().values_list('name', flat=True)
+ criteria = Q(name__in=built_recipe_names) & Q(project=self.project)
+ queryset = CustomImageRecipe.objects.filter(criteria).order_by('name')
+ return queryset
def get_outcome_text(self):
return Build.BUILD_OUTCOME[int(self.outcome)][1]
@@ -1380,6 +1384,9 @@ class Layer(models.Model):
# LayerCommit class is synced with layerindex.LayerBranch
class Layer_Version(models.Model):
+ """
+ A Layer_Version either belongs to a single project or no project
+ """
search_allowed_fields = ["layer__name", "layer__summary", "layer__description", "layer__vcs_url", "dirpath", "up_branch__name", "commit", "branch"]
build = models.ForeignKey(Build, related_name='layer_version_build', default = None, null = True)
layer = models.ForeignKey(Layer, related_name='layer_version_layer')