aboutsummaryrefslogtreecommitdiffstats
path: root/layerindex/views.py
diff options
context:
space:
mode:
authorAmanda Brindle <amanda.r.brindle@intel.com>2017-11-07 14:31:38 -0800
committerPaul Eggleton <paul.eggleton@linux.intel.com>2017-12-05 10:01:10 +1300
commita64bfed81b3827503ff825090f1fb4b94e1cd9bd (patch)
treebc0a3c454cbfc938b7c27e3d4df9b3e39331fb6d /layerindex/views.py
parent78c2561181f07b1c39f1dc3516a9110a39d874f2 (diff)
downloadopenembedded-core-contrib-a64bfed81b3827503ff825090f1fb4b94e1cd9bd.tar.gz
recipes.html: Require keyword for recipe search
Use JavaScript to check if the search box for recipe search is empty before querying the database. This will prevent the "502 Bad Gateway" error that occurs when the query takes too long due to the large list of recipes. Since there are so many recipes spread across the layers in the OE index, there's no point in allowing a user to search without a keyword in order to browse the list; it simply isn't digestible as a whole. For the Machines, Classes, and Distros pages, the search behaviour is unaffected, however to make it more obvious that you can browse the list add an explicit "browse" button. Fixes [YOCTO #11930] Signed-off-by: Amanda Brindle <amanda.r.brindle@intel.com> Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com>
Diffstat (limited to 'layerindex/views.py')
-rw-r--r--layerindex/views.py15
1 files changed, 12 insertions, 3 deletions
diff --git a/layerindex/views.py b/layerindex/views.py
index 03d47f2f49..414c770451 100644
--- a/layerindex/views.py
+++ b/layerindex/views.py
@@ -656,7 +656,10 @@ class MachineSearchView(ListView):
def get_queryset(self):
_check_url_branch(self.kwargs)
- query_string = self.request.GET.get('q', '')
+ if self.request.GET.get('search', ''):
+ query_string = self.request.GET.get('q', '')
+ else:
+ query_string = ""
init_qs = Machine.objects.filter(layerbranch__branch__name=self.kwargs['branch'])
if query_string.strip():
entry_query = simplesearch.get_query(query_string, ['name', 'description'])
@@ -705,7 +708,10 @@ class DistroSearchView(ListView):
def get_queryset(self):
_check_url_branch(self.kwargs)
- query_string = self.request.GET.get('q', '')
+ if self.request.GET.get('search', ''):
+ query_string = self.request.GET.get('q', '')
+ else:
+ query_string = ""
init_qs = Distro.objects.filter(layerbranch__branch__name=self.kwargs['branch'])
if query_string.strip():
entry_query = simplesearch.get_query(query_string, ['name', 'description'])
@@ -730,7 +736,10 @@ class ClassSearchView(ListView):
def get_queryset(self):
_check_url_branch(self.kwargs)
- query_string = self.request.GET.get('q', '')
+ if self.request.GET.get('search', ''):
+ query_string = self.request.GET.get('q', '')
+ else:
+ query_string = ""
init_qs = BBClass.objects.filter(layerbranch__branch__name=self.kwargs['branch'])
if query_string.strip():
entry_query = simplesearch.get_query(query_string, ['name'])