File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 55from ietf .person .fields import json_emails
66
77def ajax_search_emails (request ):
8- q = request .GET .get ('q' , '' ).strip ()
9- emails = Email .objects .filter (Q (person__alias__name__icontains = q ) |
10- Q (address__icontains = q ))
8+ q = [w .strip () for w in request .GET .get ('q' , '' ).split () if w .strip ()]
9+ if not q :
10+ emails = Email .objects .none ()
11+ else :
12+ query = Q ()
13+ for t in q :
14+ query &= Q (person__alias__name__icontains = t ) | Q (address__icontains = t )
15+
16+ emails = Email .objects .filter (query ).exclude (person = None )
17+
1118 if request .GET .get ("user" ) == "1" :
1219 emails = emails .exclude (person__user = None ) # require an account at the Datatracker
20+
1321 emails = emails .filter (active = True ).order_by ('person__name' ).distinct ()[:10 ]
1422 return HttpResponse (json_emails (emails ), content_type = 'application/json' )
You can’t perform that action at this time.
0 commit comments