summaryrefslogtreecommitdiff
path: root/packages/views
diff options
context:
space:
mode:
authorLuke Shumaker <lukeshu@sbcglobal.net>2015-04-15 01:40:48 -0400
committerLuke Shumaker <lukeshu@sbcglobal.net>2015-04-15 01:40:48 -0400
commitcdff1a234be0d625c5c824707dbae32ffa6a76dd (patch)
treea9e029f2a98ad72e64d9e09a922ec39ab502a75b /packages/views
parentf18a6c809f45e71175ced6050d7e57bf4e7e89ba (diff)
parent90873ef7de4bf842fbf6971836a373c555cfcbaa (diff)
Merge branch 'master-nomake'
Diffstat (limited to 'packages/views')
-rw-r--r--packages/views/__init__.py4
-rw-r--r--packages/views/search.py6
2 files changed, 8 insertions, 2 deletions
diff --git a/packages/views/__init__.py b/packages/views/__init__.py
index 1f8a0169..f3d64548 100644
--- a/packages/views/__init__.py
+++ b/packages/views/__init__.py
@@ -35,7 +35,7 @@ def opensearch(request):
@require_safe
-@cache_control(public=True, max_age=300)
+@cache_control(public=True, max_age=613)
def opensearch_suggest(request):
search_term = request.GET.get('q', '')
if search_term == '':
@@ -55,7 +55,7 @@ def opensearch_suggest(request):
'pkgname', flat=True).order_by('pkgname').distinct()[:10]
results = [search_term, list(names)]
to_json = json.dumps(results, ensure_ascii=False)
- cache.set(cache_key, to_json, 300)
+ cache.set(cache_key, to_json, 613)
return HttpResponse(to_json, content_type='application/x-suggestions+json')
diff --git a/packages/views/search.py b/packages/views/search.py
index b3778172..0b776d79 100644
--- a/packages/views/search.py
+++ b/packages/views/search.py
@@ -45,6 +45,12 @@ class PackageSearchForm(forms.Form):
[('', 'All'), ('unknown', 'Unknown')] + \
[(m.username, m.get_full_name()) for m in maints]
+ def exact_matches(self):
+ # only do exact match search if 'q' is sole parameter
+ if self.changed_data != ['q']:
+ return []
+ return Package.objects.normal().filter(pkgname=self.cleaned_data['q'])
+
def parse_form(form, packages):
if form.cleaned_data['repo']: