diff options
author | Jelte Fennema-Nio | 2024-09-24 20:29:32 +0000 |
---|---|---|
committer | Magnus Hagander | 2024-09-24 20:29:32 +0000 |
commit | 7a80d4e58a91598a6a496fbcbe75b421b77b6cf8 (patch) | |
tree | a73995264d54f973f86a3cfbbd0d134cdff98d35 | |
parent | 820e2558613a03a44c077dc107019c985fca1bb7 (diff) |
Redirect straight to patch if search finds only one
-rw-r--r-- | pgcommitfest/commitfest/views.py | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/pgcommitfest/commitfest/views.py b/pgcommitfest/commitfest/views.py index c47a388..7129f67 100644 --- a/pgcommitfest/commitfest/views.py +++ b/pgcommitfest/commitfest/views.py @@ -255,7 +255,11 @@ def global_search(request): return HttpResponseRedirect('/') searchterm = request.GET['searchterm'] - patches = Patch.objects.select_related().filter(name__icontains=searchterm).order_by('created',) + patches = Patch.objects.select_related().filter(name__icontains=searchterm).order_by('created',).all() + + if len(patches) == 1: + patch = patches[0] + return HttpResponseRedirect(f'/patch/{patch.id}/') return render(request, 'patchsearch.html', { 'patches': patches, |