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
ed5943b8
Commit
ed5943b8
authored
Aug 25, 2016
by
Serge S. Koval
Committed by
GitHub
Aug 25, 2016
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1320 from iurisilvio/fix_named_filters_l10n
Fix url generation with localized named filters.
parents
4348d60b
abad6601
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
31 additions
and
1 deletion
+31
-1
base.py
flask_admin/model/base.py
+9
-1
test_basic.py
flask_admin/tests/sqla/test_basic.py
+22
-0
No files found.
flask_admin/model/base.py
View file @
ed5943b8
...
@@ -1117,7 +1117,15 @@ class BaseModelView(BaseView, ActionsMixin):
...
@@ -1117,7 +1117,15 @@ class BaseModelView(BaseView, ActionsMixin):
Filter instance
Filter instance
"""
"""
if
self
.
named_filter_urls
:
if
self
.
named_filter_urls
:
name
=
(
'
%
s
%
s'
%
(
flt
.
name
,
as_unicode
(
flt
.
operation
())))
.
lower
()
operation
=
flt
.
operation
()
try
:
# get lazy string original value
operation
=
operation
.
_args
[
0
]
except
AttributeError
:
pass
name
=
(
'
%
s
%
s'
%
(
flt
.
name
,
as_unicode
(
operation
)))
.
lower
()
name
=
filter_char_re
.
sub
(
''
,
name
)
name
=
filter_char_re
.
sub
(
''
,
name
)
name
=
filter_compact_re
.
sub
(
'_'
,
name
)
name
=
filter_compact_re
.
sub
(
'_'
,
name
)
return
name
return
name
...
...
flask_admin/tests/sqla/test_basic.py
View file @
ed5943b8
...
@@ -1834,6 +1834,28 @@ def test_modelview_localization():
...
@@ -1834,6 +1834,28 @@ def test_modelview_localization():
for
locale
in
locales
:
for
locale
in
locales
:
test_locale
(
locale
)
test_locale
(
locale
)
def
test_modelview_named_filter_localization
():
app
,
db
,
admin
=
setup
()
app
.
config
[
'BABEL_DEFAULT_LOCALE'
]
=
'de'
Babel
(
app
)
Model1
,
_
=
create_models
(
db
)
view
=
CustomModelView
(
Model1
,
db
.
session
,
named_filter_urls
=
True
,
column_filters
=
[
'test1'
],
)
filters
=
view
.
get_filters
()
flt
=
filters
[
2
]
with
app
.
test_request_context
():
flt_name
=
view
.
get_filter_arg
(
2
,
flt
)
eq_
(
'test1_equals'
,
flt_name
)
def
test_custom_form_base
():
def
test_custom_form_base
():
app
,
db
,
admin
=
setup
()
app
,
db
,
admin
=
setup
()
...
...
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