Skip to content

Commit 7a80d4e

Browse files
JelteFmhagander
authored andcommitted
Redirect straight to patch if search finds only one
1 parent 820e255 commit 7a80d4e

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

pgcommitfest/commitfest/views.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,11 @@ def global_search(request):
255255
return HttpResponseRedirect('/')
256256
searchterm = request.GET['searchterm']
257257

258-
patches = Patch.objects.select_related().filter(name__icontains=searchterm).order_by('created',)
258+
patches = Patch.objects.select_related().filter(name__icontains=searchterm).order_by('created',).all()
259+
260+
if len(patches) == 1:
261+
patch = patches[0]
262+
return HttpResponseRedirect(f'/patch/{patch.id}/')
259263

260264
return render(request, 'patchsearch.html', {
261265
'patches': patches,

0 commit comments

Comments
 (0)