Commit fdd87025 authored by PJ Janse van Rensburg's avatar PJ Janse van Rensburg

Merge branch 'case-insensitive-filter' of https://github.com/jnga/flask-admin...

Merge branch 'case-insensitive-filter' of https://github.com/jnga/flask-admin into case-insensitive-mongo
parents 1f3d1b72 6bf28ccf
def parse_like_term(term):
"""
Parse search term into (operation, term) tuple. Recognizes operators
in the beginning of the search term.
in the beginning of the search term. Case insensitive is the default.
* = case insensitive (can precede other operators)
* = case sensitive (can precede other operators)
^ = starts with
= = exact
:param term:
Search term
"""
case_insensitive = term.startswith('*')
if case_insensitive:
case_sensitive = term.startswith('*')
if case_sensitive:
term = term[1:]
# apply operators
if term.startswith('^'):
......@@ -23,6 +23,6 @@ def parse_like_term(term):
else:
oper = 'contains'
# add case insensitive flag
if case_insensitive:
if not case_sensitive:
oper = 'i' + oper
return oper, term
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment