diff --git a/layerindex/models.py b/layerindex/models.py index e1a9edd..ae9509a 100644 --- a/layerindex/models.py +++ b/layerindex/models.py @@ -337,6 +337,16 @@ class BBAppend(models.Model): url = self.layerbranch.file_url(os.path.join(self.filepath, self.filename)) return url or '' + def matches_recipe(self, recipe): + recipename = recipe.filename[:-3] + appendname = self.filename[:-9] + if recipename == appendname: + return True + elif '%' in appendname: + import fnmatch + return fnmatch.fnmatch(recipename, appendname.replace('%', '*')) + return False + def __unicode__(self): return os.path.join(self.filepath, self.filename) diff --git a/layerindex/views.py b/layerindex/views.py index 4b0afab..0ea794e 100644 --- a/layerindex/views.py +++ b/layerindex/views.py @@ -656,8 +656,15 @@ class RecipeDetailView(DetailView): context = super(RecipeDetailView, self).get_context_data(**kwargs) recipe = self.get_object() if recipe: - appendprefix = "%s_" % recipe.pn - context['appends'] = BBAppend.objects.filter(layerbranch__branch=recipe.layerbranch.branch).filter(filename__startswith=appendprefix) + verappendprefix = recipe.filename.split('.bb')[0] + appendprefix = verappendprefix.split('_')[0] + #context['verappends'] = BBAppend.objects.filter(layerbranch__branch=recipe.layerbranch.branch).filter(filename='%s.bbappend' % verappendprefix) + context['appends'] = BBAppend.objects.filter(layerbranch__branch=recipe.layerbranch.branch).filter(filename__regex=r'%s(_[^_]*)?\.bbappend' % appendprefix) + verappends = [] + for append in context['appends']: + if append.matches_recipe(recipe): + verappends.append(append) + context['verappends'] = verappends return context diff --git a/templates/layerindex/recipedetail.html b/templates/layerindex/recipedetail.html index dec477c..658694e 100644 --- a/templates/layerindex/recipedetail.html +++ b/templates/layerindex/recipedetail.html @@ -90,7 +90,7 @@
This recipe is appended by:
{{ append.layerbranch.layer.name }} @@ -100,6 +100,18 @@ | |
+ {{ append.layerbranch.layer.name }} + | ++ {{ append.filename }} + | +