When the recipe search returns a single result, redirect to it instead of showing the full result list view.
[YOCTO #6618] Signed-off-by: Alex Franco <[email protected]> --- layerindex/views.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/layerindex/views.py b/layerindex/views.py index 7e877ac..8be3311 100644 --- a/layerindex/views.py +++ b/layerindex/views.py @@ -368,6 +368,12 @@ class RecipeSearchView(ListView): context_object_name = 'recipe_list' paginate_by = 50 + def render_to_response(self, context, **kwargs): + if len(self.object_list) == 1: + return HttpResponseRedirect("/layerindex/recipe/%s/" % self.object_list[0].id) + else: + return super(ListView, self).render_to_response(context, **kwargs) + def get_queryset(self): _check_url_branch(self.kwargs) query_string = self.request.GET.get('q', '') -- 2.6.1 -- _______________________________________________ yocto mailing list [email protected] https://lists.yoctoproject.org/listinfo/yocto
