views: fix "layer:" keyword on recipe search page

We were using the layerbranch id to search for the specified layer,
which is most likely to return either no results or results for the
wrong layer. We can also avoid specifying the id field at all here as
the filter() function can handle real objects.

Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com>
This commit is contained in:
Paul Eggleton 2018-01-09 15:27:52 +13:00
parent 8dd24abf99
commit 21f343201d

View File

@ -449,11 +449,11 @@ class RecipeSearchView(ListView):
messages.add_message(self.request, messages.ERROR, 'The \
layer name is expected to follow the \"layer:\" prefix without any spaces.')
else:
query_layer = LayerBranch.objects.filter(
layer__name=query_layername)
query_layer = LayerItem.objects.filter(
name=query_layername)
if query_layer:
init_qs = init_qs.filter(
layerbranch__layer__id=query_layer[0].id)
layerbranch__layer=query_layer[0])
else:
messages.add_message(self.request, messages.ERROR,
'No layer \"%s\" was found.'