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
abad6601
Commit
abad6601
authored
Jul 26, 2016
by
Iuri de Silvio
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix url generation with localized named filters.
parent
8563ecdd
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 @
abad6601
...
...
@@ -1117,7 +1117,15 @@ class BaseModelView(BaseView, ActionsMixin):
Filter instance
"""
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_compact_re
.
sub
(
'_'
,
name
)
return
name
...
...
flask_admin/tests/sqla/test_basic.py
View file @
abad6601
...
...
@@ -1834,6 +1834,28 @@ def test_modelview_localization():
for
locale
in
locales
:
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
():
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