File tree Expand file tree Collapse file tree 1 file changed +10
-2
lines changed Expand file tree Collapse file tree 1 file changed +10
-2
lines changed Original file line number Diff line number Diff line change 1+ import functools
2+ import operator
3+
14from agagd_core .models import Member
25from agagd_core .tables .search import SearchResultsTable
36from django .db .models import F , Q
@@ -13,7 +16,7 @@ class SearchView(DetailView):
1316 search_results_template_name = "search_results.html"
1417
1518 def get (self , request ):
16- query = request .GET .get ("q" , "" )
19+ query = request .GET .get ("q" , "" ). strip ()
1720
1821 if not query :
1922 return TemplateResponse (request , self .template_name )
@@ -22,9 +25,14 @@ def get(self, request):
2225 member_id = [int (query )]
2326 return HttpResponseRedirect (reverse ("players_profile" , args = member_id ))
2427
28+ # constructing intersection queryset from query tokens
29+ tokens = query .split ()
30+ querysets = (Q (full_name__icontains = token ) for token in tokens )
31+ queryset = functools .reduce (operator .and_ , querysets )
32+
2533 member_table_data = (
2634 Member .objects .filter (Q (member_id = F ("players__pin_player" )))
27- .filter (full_name__icontains = query )
35+ .filter (queryset )
2836 .values (
2937 "member_id" ,
3038 "chapter_id" ,
You can’t perform that action at this time.
0 commit comments