Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
F
flask-admin
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
JIRA
JIRA
Merge Requests
0
Merge Requests
0
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Python-Dev
flask-admin
Commits
d7c5ff08
Commit
d7c5ff08
authored
Oct 07, 2018
by
PJ Janse van Rensburg
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'case-insensitive-mongo'
parents
1f3d1b72
5444acf2
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
6 additions
and
5 deletions
+6
-5
changelog.rst
doc/changelog.rst
+1
-0
tools.py
flask_admin/contrib/mongoengine/tools.py
+5
-5
No files found.
doc/changelog.rst
View file @
d7c5ff08
...
@@ -8,6 +8,7 @@ next release
...
@@ -8,6 +8,7 @@ next release
* Upgrade Leaflet and Leaflet.draw plugins, used for geoalchemy integration
* Upgrade Leaflet and Leaflet.draw plugins, used for geoalchemy integration
* Specify `minimum_input_length` for ajax widget
* Specify `minimum_input_length` for ajax widget
* SQLAlchemy fix that lets you use inline model forms where models have multiple primary keys
* SQLAlchemy fix that lets you use inline model forms where models have multiple primary keys
* MongoEngine: when searching/filtering the input is now regarded as case-insensitive by default
1.5.2
1.5.2
-----
-----
...
...
flask_admin/contrib/mongoengine/tools.py
View file @
d7c5ff08
def
parse_like_term
(
term
):
def
parse_like_term
(
term
):
"""
"""
Parse search term into (operation, term) tuple. Recognizes operators
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
in
sensitive (can precede other operators)
* = case sensitive (can precede other operators)
^ = starts with
^ = starts with
= = exact
= = exact
:param term:
:param term:
Search term
Search term
"""
"""
case_
in
sensitive
=
term
.
startswith
(
'*'
)
case_sensitive
=
term
.
startswith
(
'*'
)
if
case_
in
sensitive
:
if
case_sensitive
:
term
=
term
[
1
:]
term
=
term
[
1
:]
# apply operators
# apply operators
if
term
.
startswith
(
'^'
):
if
term
.
startswith
(
'^'
):
...
@@ -23,6 +23,6 @@ def parse_like_term(term):
...
@@ -23,6 +23,6 @@ def parse_like_term(term):
else
:
else
:
oper
=
'contains'
oper
=
'contains'
# add case insensitive flag
# add case insensitive flag
if
case_in
sensitive
:
if
not
case_
sensitive
:
oper
=
'i'
+
oper
oper
=
'i'
+
oper
return
oper
,
term
return
oper
,
term
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment