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
9cae4b37
Commit
9cae4b37
authored
Jul 04, 2018
by
idk
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add possibility to change message, which will be printed in case of invalid value.
parent
c1a8164a
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
7 deletions
+17
-7
base.py
flask_admin/model/base.py
+17
-7
No files found.
flask_admin/model/base.py
View file @
9cae4b37
...
@@ -1648,29 +1648,39 @@ class BaseModelView(BaseView, ActionsMixin):
...
@@ -1648,29 +1648,39 @@ class BaseModelView(BaseView, ActionsMixin):
def
get_empty_list_message
(
self
):
def
get_empty_list_message
(
self
):
return
gettext
(
'There are no items in the table.'
)
return
gettext
(
'There are no items in the table.'
)
def
get_invalid_value_msg
(
self
,
value
,
filter
):
"""
Returns message, which should be printed in case of failed validation.
:param value: Invalid value
:param filter: Filter
:return: string
"""
return
gettext
(
'Invalid Filter Value:
%(value)
s'
,
value
=
value
)
# URL generation helpers
# URL generation helpers
def
_get_list_filter_args
(
self
):
def
_get_list_filter_args
(
self
):
if
self
.
_filters
:
if
self
.
_filters
:
filters
=
[]
filters
=
[]
for
n
in
request
.
args
:
for
arg
in
request
.
args
:
if
not
n
.
startswith
(
'flt'
):
if
not
arg
.
startswith
(
'flt'
):
continue
continue
if
'_'
not
in
n
:
if
'_'
not
in
arg
:
continue
continue
pos
,
key
=
n
[
3
:]
.
split
(
'_'
,
1
)
pos
,
key
=
arg
[
3
:]
.
split
(
'_'
,
1
)
if
key
in
self
.
_filter_args
:
if
key
in
self
.
_filter_args
:
idx
,
flt
=
self
.
_filter_args
[
key
]
idx
,
flt
=
self
.
_filter_args
[
key
]
value
=
request
.
args
[
n
]
value
=
request
.
args
[
arg
]
if
flt
.
validate
(
value
):
if
flt
.
validate
(
value
):
filters
.
append
((
pos
,
(
idx
,
as_unicode
(
flt
.
name
),
value
)))
data
=
(
pos
,
(
idx
,
as_unicode
(
flt
.
name
),
value
))
filters
.
append
(
data
)
else
:
else
:
flash
(
gettext
(
'Invalid Filter Value:
%(value)
s'
,
value
=
value
),
'error'
)
flash
(
self
.
get_invalid_value_msg
(
value
,
flt
),
'error'
)
# Sort filters
# Sort filters
return
[
v
[
1
]
for
v
in
sorted
(
filters
,
key
=
lambda
n
:
n
[
0
])]
return
[
v
[
1
]
for
v
in
sorted
(
filters
,
key
=
lambda
n
:
n
[
0
])]
...
...
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