From: Magnus Hagander Date: Tue, 7 Oct 2025 12:49:57 +0000 (+0200) Subject: Allow check-in searches on multiple words to be split X-Git-Url: http://git.postgresql.org/gitweb/static/%7B%7Bpgdulink%28?a=commitdiff_plain;h=9ff684602daed2db5d614d7ce9430f64b4a33f3f;p=pgeu-system.git Allow check-in searches on multiple words to be split Previously a search for "first last" would require it to be specified exactly like that as part of either first or last name, and thus unlikely ever match anything. Change that to split the search string on whitespace and search individually for each of the names. Fixes #191 --- diff --git a/postgresqleu/confreg/checkin.py b/postgresqleu/confreg/checkin.py index c38d35f1..84dde1e4 100644 --- a/postgresqleu/confreg/checkin.py +++ b/postgresqleu/confreg/checkin.py @@ -314,9 +314,15 @@ def api(request, urlname, regtoken, what): return _json_response({'reg': _get_reg_json(r)}) elif what == 'search': s = request.GET.get('search').strip() + q = Q() + for n in s.split(): + # For each part of the given string, search both first and last name + # When two or more name parts are specified, require that they all match, + # but don't care which one matches which part. + q = q & (Q(firstname__icontains=n) | Q(lastname__icontains=n)) return _json_response({ 'regs': [_get_reg_json(r) for r in ConferenceRegistration.objects.filter( - Q(firstname__icontains=s) | Q(lastname__icontains=s), + q, conference=conference, payconfirmedat__isnull=False, canceledat__isnull=True, )], })