Allow searching for members by email
This commit is contained in:
parent
3a9fd875b2
commit
a3db260e08
|
@ -143,7 +143,14 @@ def gen_search_strings():
|
||||||
string = '{} {}'.format(
|
string = '{} {}'.format(
|
||||||
m.preferred_name,
|
m.preferred_name,
|
||||||
m.last_name,
|
m.last_name,
|
||||||
).lower()
|
)
|
||||||
|
|
||||||
|
if m.old_email:
|
||||||
|
string += ' ' + m.old_email
|
||||||
|
if m.user:
|
||||||
|
string += ' ' + m.user.email
|
||||||
|
|
||||||
|
string = string.lower()
|
||||||
search_strings[string] = m.id
|
search_strings[string] = m.id
|
||||||
cache.set('search_strings', search_strings)
|
cache.set('search_strings', search_strings)
|
||||||
|
|
||||||
|
|
|
@ -69,8 +69,8 @@ class SearchViewSet(Base, Retrieve):
|
||||||
# then get exact substring matches
|
# then get exact substring matches
|
||||||
results += [x for x in choices if search in x]
|
results += [x for x in choices if search in x]
|
||||||
|
|
||||||
if len(results) == 0 and len(search) >= 3:
|
if len(results) == 0 and len(search) >= 3 and '@' not in search:
|
||||||
# then get fuzzy matches
|
# then get fuzzy matches, but not for emails
|
||||||
fuzzy_results = process.extract(search, choices, limit=NUM_SEARCH_RESULTS, scorer=fuzz.token_set_ratio)
|
fuzzy_results = process.extract(search, choices, limit=NUM_SEARCH_RESULTS, scorer=fuzz.token_set_ratio)
|
||||||
results += [x[0] for x in fuzzy_results]
|
results += [x[0] for x in fuzzy_results]
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user