[yocto] [layerindex-web][PATCH 1/2] views.py: Redirect to recipe details for single results

Jose Lamego jose.a.lamego at linux.intel.com
Mon Mar 13 13:35:16 PDT 2017


Ping.

On 01/18/2017 04:19 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

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 473 bytes
Desc: OpenPGP digital signature
URL: <http://lists.yoctoproject.org/pipermail/yocto/attachments/20170313/8e70454d/attachment.pgp>


More information about the yocto mailing list