mirror of
git://git.yoctoproject.org/layerindex-web.git
synced 2025-07-19 20:59:01 +02:00
views.py: single result redirect
When the recipe search returns a single result, redirect to it instead of showing the full result list view. Part of the fix for [YOCTO #6618]. Signed-off-by: Alex Franco <alejandro.franco@linux.intel.com> Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com>
This commit is contained in:
parent
b1c5b15ae8
commit
c8c25fb641
|
@ -372,6 +372,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(reverse('recipe', args=(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', '')
|
||||
|
|
Loading…
Reference in New Issue
Block a user