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
3c879622
Commit
3c879622
authored
Dec 11, 2015
by
Iuri de Silvio
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix #1122 filter options translations.
The lazy_gettext was evaluated too soon, before the translator is ready.
parent
47d965fb
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
8 additions
and
6 deletions
+8
-6
base.py
flask_admin/model/base.py
+5
-2
filters.py
flask_admin/model/filters.py
+1
-2
test_model.py
flask_admin/tests/test_model.py
+2
-2
No files found.
flask_admin/model/base.py
View file @
3c879622
...
...
@@ -23,7 +23,7 @@ from flask_admin.helpers import (get_form_data, validate_form_on_submit,
from
flask_admin.tools
import
rec_getattr
from
flask_admin._backwards
import
ObsoleteAttr
from
flask_admin._compat
import
(
iteritems
,
itervalues
,
OrderedDict
,
as_unicode
,
csv_encode
)
as_unicode
,
csv_encode
,
text_type
)
from
.helpers
import
prettify_name
,
get_mdict_item_or_list
from
.ajax
import
AjaxModelLoader
from
.fields
import
ListEditableFieldList
...
...
@@ -78,6 +78,10 @@ class FilterGroup(object):
for
item
in
self
.
filters
:
copy
=
dict
(
item
)
copy
[
'operation'
]
=
as_unicode
(
copy
[
'operation'
])
options
=
copy
[
'options'
]
if
options
:
copy
[
'options'
]
=
[(
k
,
text_type
(
v
))
for
k
,
v
in
options
]
filters
.
append
(
copy
)
return
as_unicode
(
self
.
label
),
filters
...
...
@@ -735,7 +739,6 @@ class BaseModelView(BaseView, ActionsMixin):
key
=
as_unicode
(
flt
.
name
)
if
key
not
in
self
.
_filter_groups
:
self
.
_filter_groups
[
key
]
=
FilterGroup
(
flt
.
name
)
self
.
_filter_groups
[
key
]
.
append
({
'index'
:
i
,
'arg'
:
self
.
get_filter_arg
(
i
,
flt
),
...
...
flask_admin/model/filters.py
View file @
3c879622
import
time
import
datetime
from
flask_admin._compat
import
text_type
from
flask_admin.babel
import
lazy_gettext
...
...
@@ -39,7 +38,7 @@ class BaseFilter(object):
if
callable
(
options
):
options
=
options
()
return
[(
v
,
text_type
(
n
))
for
v
,
n
in
options
]
return
options
return
None
...
...
flask_admin/tests/test_model.py
View file @
3c879622
...
...
@@ -326,14 +326,14 @@ def test_column_filters():
def
test_filter_list_callable
():
app
,
admin
=
setup
()
flt
=
SimpleFilter
(
'test'
,
options
=
lambda
:
((
'1'
,
'Test 1'
),
(
'2'
,
'Test 2'
))
)
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'
)])
eq_
(
opts
,
[(
'1'
,
'Test 1'
),
(
'2'
,
'Test 2'
)])
def
test_form
():
...
...
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