Commit e11ac201 authored by Serge S. Koval's avatar Serge S. Koval

Merge pull request #177 from cbess/master

Allow case-insensitive searches in admin
parents 22853154 da0add4f
def parse_like_term(term): def parse_like_term(term):
""" """
Parse search term into (operation, term) tuple Parse search term into (operation, term) tuple. Recognizes operators
in the beginning of the search term.
* = case insensitive (can precede other operators)
^ = starts with
= = exact
:param term: :param term:
Search term Search term
""" """
case_insensitive = term.startswith('*')
if case_insensitive:
term = term[1:]
# apply operators
if term.startswith('^'): if term.startswith('^'):
return 'startswith', term[1:] oper = 'startswith'
term = term[1:]
elif term.startswith('='): elif term.startswith('='):
return 'exact', term[1:] oper = 'exact'
term = term[1:]
return 'contains', term else:
oper = 'contains'
# add case insensitive flag
if case_insensitive:
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