[yocto] [layerindex-web][PATCH 1/2] views.py: Redirect to recipe details for single results
Jose Lamego
jose.a.lamego at linux.intel.com
Tue Jan 24 10:47:27 PST 2017
ping
On 01/18/2017 04:31 PM, Jose Lamego wrote:
> From: Alex Franco <alejandro.franco at linux.intel.com>
>
> When a recipe search returns only one result, clicking the single
> result at the results view is still required to view further
> recipe detail.
>
> This change automatically redirects to the recipe details view
> when the recipe search returns a single result.
>
> [YOCTO #6618]
>
> Signed-off-by: Jose Lamego <jose.a.lamego at linux.intel.com>
> ---
> layerindex/views.py | 8 ++++++++
> 1 file changed, 8 insertions(+)
>
> diff --git a/layerindex/views.py b/layerindex/views.py
> index 0f73e93..03fadbb 100644
> --- a/layerindex/views.py
> +++ b/layerindex/views.py
> @@ -372,6 +372,14 @@ 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', '')
>
--
Jose Lamego | OTC Embedded Platforms & Tools | GDC
More information about the yocto
mailing list