views.py: Redirect to recipe details for single results
A message that is not in the archive (sent off-list or not yet received): [email protected]
A message that is not in the archive (sent off-list or not yet received): [email protected]
Ping.
Quoted 36 lines · Jose Lamego
From: Alex Franco <[email protected]>
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 <[email protected]>--- layerindex/views.py | 8 ++++++++ 1 file changed, 8 insertions(+)layerindex/views.py +8
-0@@ -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', '')
Signature · 1 line
Jose Lamego | OTC Embedded Platforms & Tools | GDC
This should be using a reverse() call instead of a hardcoded URL path suffix. However, since that was a trivial fix I've done that and merged it - it'll appear in the layer index once we do the next upgrade (fairly soon).
Cheers,
Paul
Quoted 41 lines · NZDT Jose Lamego
Ping.
Quoted 38 lines · Jose Lamego
From: Alex Franco <[email protected]>
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 <[email protected]>---
layerindex/views.py | 8 ++++++++ 1 file changed, 8 insertions(+)layerindex/views.py +8
-0@@ -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', '')
Signature · 2 lines
Paul Eggleton Intel Open Source Technology Centre
A message that is not in the archive (sent off-list or not yet received): [email protected]
Re: [layerindex-web][PATCH 2/2] views.py: Consider layer name in recipe search
Ping.
Quoted 31 lines · Jose Lamego
From: Alex Franco <[email protected]>
Recipe search cannot be narrowed to a specific layer, producing unnecessary results.
This change allows including a layers name when searching for recipes to narrow the yielded results by adding a layer name to the simplesearch.getquery call in the recipe search view.
[YOCTO #6618]
Signed-off-by Jose Lamego <[email protected]>--- layerindex/views.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)layerindex/views.py +2
-1@@ -406,7 +406,8 @@ class RecipeSearchView(ListView): qs0 = init_qs.filter(pn=query_string).order_by(*order_by) qs0 = recipes_preferred_count(qs0) - entry_query = simplesearch.get_query(query_string, ['pn']) + entry_query = simplesearch.get_query( + query_string, ['pn', 'layerbranch__layer__name']) qs1 = init_qs.filter(entry_query).order_by(*order_by) qs1 = recipes_preferred_count(qs1)
Signature · 1 line
Jose Lamego | OTC Embedded Platforms & Tools | GDC
Re: [layerindex-web][PATCH 2/2] views.py: Consider layer name in recipe search
Hi Jose,
Sorry for the delay in responding to this.
I'd prefer if this were implemented like the recently added "inherits:" where we have a special prefix e.g. "layer:" in order to search for things in a particular layer. Then it's much clearer as to what's going on.
Cheers,
Paul
Quoted 35 lines · NZDT Jose Lamego
Ping.
Quoted 32 lines · Jose Lamego
From: Alex Franco <[email protected]>
Recipe search cannot be narrowed to a specific layer, producing unnecessary results.
This change allows including a layers name when searching for recipes to narrow the yielded results by adding a layer name to the simplesearch.getquery call in the recipe search view.
[YOCTO #6618]
Signed-off-by Jose Lamego <[email protected]>---
layerindex/views.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)layerindex/views.py +2
-1@@ -406,7 +406,8 @@ class RecipeSearchView(ListView): qs0 = init_qs.filter(pn=query_string).order_by(*order_by) qs0 = recipes_preferred_count(qs0) - entry_query = simplesearch.get_query(query_string, ['pn']) + entry_query = simplesearch.get_query( + query_string, ['pn', 'layerbranch__layer__name']) qs1 = init_qs.filter(entry_query).order_by(*order_by) qs1 = recipes_preferred_count(qs1)
Signature · 2 lines
Paul Eggleton Intel Open Source Technology Centre
Re: [layerindex-web][PATCH 2/2] views.py: Consider layer name in recipe search
Quoted 8 lines · Paul Eggleton
Hi Jose,
Sorry for the delay in responding to this.
I'd prefer if this were implemented like the recently added "inherits:" where we have a special prefix e.g. "layer:" in order to search for things in a particular layer. Then it's much clearer as to what's going on.
I've submitted a new patch following this approach:
https://lists.yoctoproject.org/pipermail/yocto/2017-April/035451.html
Quoted 41 lines
Cheers,
PaulQuoted 35 lines · NZDT Jose Lamego
Ping.
Quoted 32 lines · Jose Lamego
From: Alex Franco <[email protected]>
Recipe search cannot be narrowed to a specific layer, producing unnecessary results.
This change allows including a layers name when searching for recipes to narrow the yielded results by adding a layer name to the simplesearch.getquery call in the recipe search view.
[YOCTO #6618]
Signed-off-by Jose Lamego <[email protected]>---
layerindex/views.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)layerindex/views.py +2
-1@@ -406,7 +406,8 @@ class RecipeSearchView(ListView): qs0 = init_qs.filter(pn=query_string).order_by(*order_by) qs0 = recipes_preferred_count(qs0) - entry_query = simplesearch.get_query(query_string, ['pn']) + entry_query = simplesearch.get_query( + query_string, ['pn', 'layerbranch__layer__name']) qs1 = init_qs.filter(entry_query).order_by(*order_by) qs1 = recipes_preferred_count(qs1)
Signature · 1 line
Jose Lamego | OTC Embedded Platforms & Tools | GDC