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
2348cf2f
Commit
2348cf2f
authored
Apr 21, 2014
by
Serge S. Koval
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed #509. Callable filter options.
parent
a76c004d
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
20 additions
and
2 deletions
+20
-2
filters.py
flask_admin/model/filters.py
+7
-2
test_model.py
flask_admin/tests/test_model.py
+13
-0
No files found.
flask_admin/model/filters.py
View file @
2348cf2f
...
@@ -30,8 +30,13 @@ class BaseFilter(object):
...
@@ -30,8 +30,13 @@ class BaseFilter(object):
:param view:
:param view:
Associated administrative view class.
Associated administrative view class.
"""
"""
if
self
.
options
:
options
=
self
.
options
return
[(
v
,
text_type
(
n
))
for
v
,
n
in
self
.
options
]
if
options
:
if
callable
(
options
):
options
=
options
()
return
[(
v
,
text_type
(
n
))
for
v
,
n
in
options
]
return
None
return
None
...
...
flask_admin/tests/test_model.py
View file @
2348cf2f
...
@@ -308,6 +308,19 @@ def test_column_filters():
...
@@ -308,6 +308,19 @@ def test_column_filters():
# TODO: Make calls with filters
# TODO: Make calls with filters
def
test_filter_list_callable
():
app
,
admin
=
setup
()
flt
=
SimpleFilter
(
'test'
,
options
=
lambda
:
((
'1'
,
'Test 1'
),
(
'2'
,
'Test 2'
)))
view
=
MockModelView
(
Model
,
column_filters
=
[
flt
])
admin
.
add_view
(
view
)
opts
=
flt
.
get_options
(
view
)
eq_
(
len
(
opts
),
2
)
eq_
(
opts
,
[(
'1'
,
u'Test 1'
),
(
'2'
,
u'Test 2'
)])
def
test_form
():
def
test_form
():
# TODO: form_columns
# TODO: form_columns
# TODO: form_excluded_columns
# TODO: form_excluded_columns
...
...
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