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
273c61ee
Commit
273c61ee
authored
May 01, 2016
by
Paul Brown
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add missing success/error to flashes
parent
0e0f0685
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
21 additions
and
21 deletions
+21
-21
__init__.py
flask_admin/contrib/fileadmin/__init__.py
+7
-7
view.py
flask_admin/contrib/mongoengine/view.py
+1
-1
view.py
flask_admin/contrib/peewee/view.py
+1
-1
view.py
flask_admin/contrib/sqla/view.py
+1
-1
base.py
flask_admin/model/base.py
+11
-11
No files found.
flask_admin/contrib/fileadmin/__init__.py
View file @
273c61ee
...
...
@@ -789,7 +789,7 @@ class BaseFileAdmin(BaseView, ActionsMixin):
try
:
self
.
_save_form_files
(
directory
,
path
,
form
)
flash
(
gettext
(
'Successfully saved file:
%(name)
s'
,
name
=
form
.
upload
.
data
.
filename
))
name
=
form
.
upload
.
data
.
filename
)
,
'success'
)
return
redirect
(
self
.
_get_dir_url
(
'.index_view'
,
path
))
except
Exception
as
ex
:
flash
(
gettext
(
'Failed to save file:
%(error)
s'
,
error
=
ex
),
'error'
)
...
...
@@ -853,7 +853,7 @@ class BaseFileAdmin(BaseView, ActionsMixin):
self
.
storage
.
make_dir
(
directory
,
form
.
name
.
data
)
self
.
on_mkdir
(
directory
,
form
.
name
.
data
)
flash
(
gettext
(
'Successfully created directory:
%(directory)
s'
,
directory
=
form
.
name
.
data
))
directory
=
form
.
name
.
data
)
,
'success'
)
return
redirect
(
dir_url
)
except
Exception
as
ex
:
flash
(
gettext
(
'Failed to create directory:
%(error)
s'
,
error
=
ex
),
'error'
)
...
...
@@ -907,7 +907,7 @@ class BaseFileAdmin(BaseView, ActionsMixin):
self
.
before_directory_delete
(
full_path
,
path
)
self
.
storage
.
delete_tree
(
full_path
)
self
.
on_directory_delete
(
full_path
,
path
)
flash
(
gettext
(
'Directory "
%(path)
s" was successfully deleted.'
,
path
=
path
))
flash
(
gettext
(
'Directory "
%(path)
s" was successfully deleted.'
,
path
=
path
)
,
'success'
)
except
Exception
as
ex
:
flash
(
gettext
(
'Failed to delete directory:
%(error)
s'
,
error
=
ex
),
'error'
)
else
:
...
...
@@ -915,7 +915,7 @@ class BaseFileAdmin(BaseView, ActionsMixin):
self
.
before_file_delete
(
full_path
,
path
)
self
.
delete_file
(
full_path
)
self
.
on_file_delete
(
full_path
,
path
)
flash
(
gettext
(
'File "
%(name)
s" was successfully deleted.'
,
name
=
path
))
flash
(
gettext
(
'File "
%(name)
s" was successfully deleted.'
,
name
=
path
)
,
'success'
)
except
Exception
as
ex
:
flash
(
gettext
(
'Failed to delete file:
%(name)
s'
,
name
=
ex
),
'error'
)
else
:
...
...
@@ -958,7 +958,7 @@ class BaseFileAdmin(BaseView, ActionsMixin):
self
.
on_rename
(
full_path
,
dir_base
,
filename
)
flash
(
gettext
(
'Successfully renamed "
%(src)
s" to "
%(dst)
s"'
,
src
=
op
.
basename
(
path
),
dst
=
filename
))
dst
=
filename
)
,
'success'
)
except
Exception
as
ex
:
flash
(
gettext
(
'Failed to rename:
%(error)
s'
,
error
=
ex
),
'error'
)
...
...
@@ -1015,7 +1015,7 @@ class BaseFileAdmin(BaseView, ActionsMixin):
error
=
True
else
:
self
.
on_edit_file
(
full_path
,
path
)
flash
(
gettext
(
"Changes to
%(name)
s saved successfully."
,
name
=
path
))
flash
(
gettext
(
"Changes to
%(name)
s saved successfully."
,
name
=
path
)
,
'success'
)
return
redirect
(
next_url
)
else
:
helpers
.
flash_errors
(
form
,
message
=
'Failed to edit file.
%(error)
s'
)
...
...
@@ -1072,7 +1072,7 @@ class BaseFileAdmin(BaseView, ActionsMixin):
if
self
.
is_accessible_path
(
path
):
try
:
self
.
delete_file
(
full_path
)
flash
(
gettext
(
'File "
%(name)
s" was successfully deleted.'
,
name
=
path
))
flash
(
gettext
(
'File "
%(name)
s" was successfully deleted.'
,
name
=
path
)
,
'success'
)
except
Exception
as
ex
:
flash
(
gettext
(
'Failed to delete file:
%(name)
s'
,
name
=
ex
),
'error'
)
...
...
flask_admin/contrib/mongoengine/view.py
View file @
273c61ee
...
...
@@ -671,7 +671,7 @@ class ModelView(BaseModelView):
flash
(
ngettext
(
'Record was successfully deleted.'
,
'
%(count)
s records were successfully deleted.'
,
count
,
count
=
count
))
count
=
count
)
,
'error'
)
except
Exception
as
ex
:
if
not
self
.
handle_view_exception
(
ex
):
flash
(
gettext
(
'Failed to delete records.
%(error)
s'
,
error
=
str
(
ex
)),
...
...
flask_admin/contrib/peewee/view.py
View file @
273c61ee
...
...
@@ -498,7 +498,7 @@ class ModelView(BaseModelView):
flash
(
ngettext
(
'Record was successfully deleted.'
,
'
%(count)
s records were successfully deleted.'
,
count
,
count
=
count
))
count
=
count
)
,
'error'
)
except
Exception
as
ex
:
if
not
self
.
handle_view_exception
(
ex
):
flash
(
gettext
(
'Failed to delete records.
%(error)
s'
,
error
=
str
(
ex
)),
'error'
)
flask_admin/contrib/sqla/view.py
View file @
273c61ee
...
...
@@ -1106,7 +1106,7 @@ class ModelView(BaseModelView):
flash
(
ngettext
(
'Record was successfully deleted.'
,
'
%(count)
s records were successfully deleted.'
,
count
,
count
=
count
))
count
=
count
)
,
'error'
)
except
Exception
as
ex
:
if
not
self
.
handle_view_exception
(
ex
):
raise
...
...
flask_admin/model/base.py
View file @
273c61ee
...
...
@@ -1438,7 +1438,7 @@ class BaseModelView(BaseView, ActionsMixin):
# Exception handler
def
handle_view_exception
(
self
,
exc
):
if
isinstance
(
exc
,
ValidationError
):
flash
(
as_unicode
(
exc
))
flash
(
as_unicode
(
exc
)
,
'error'
)
return
True
if
self
.
_debug
:
...
...
@@ -1623,7 +1623,7 @@ class BaseModelView(BaseView, ActionsMixin):
if
flt
.
validate
(
value
):
filters
.
append
((
pos
,
(
idx
,
as_unicode
(
flt
.
name
),
value
)))
else
:
flash
(
gettext
(
'Invalid Filter Value:
%(value)
s'
,
value
=
value
))
flash
(
gettext
(
'Invalid Filter Value:
%(value)
s'
,
value
=
value
)
,
'error'
)
# Sort filters
return
[
v
[
1
]
for
v
in
sorted
(
filters
,
key
=
lambda
n
:
n
[
0
])]
...
...
@@ -1916,7 +1916,7 @@ class BaseModelView(BaseView, ActionsMixin):
# in later versions, this is the model itself
model
=
self
.
create_model
(
form
)
if
model
:
flash
(
gettext
(
'Record was successfully created.'
))
flash
(
gettext
(
'Record was successfully created.'
)
,
'success'
)
if
'_add_another'
in
request
.
form
:
return
redirect
(
request
.
url
)
elif
'_continue_editing'
in
request
.
form
:
...
...
@@ -1960,7 +1960,7 @@ class BaseModelView(BaseView, ActionsMixin):
model
=
self
.
get_one
(
id
)
if
model
is
None
:
flash
(
gettext
(
'Record does not exist.'
))
flash
(
gettext
(
'Record does not exist.'
)
,
'error'
)
return
redirect
(
return_url
)
form
=
self
.
edit_form
(
obj
=
model
)
...
...
@@ -1969,7 +1969,7 @@ class BaseModelView(BaseView, ActionsMixin):
if
self
.
validate_form
(
form
):
if
self
.
update_model
(
form
,
model
):
flash
(
gettext
(
'Record was successfully saved.'
))
flash
(
gettext
(
'Record was successfully saved.'
)
,
'success'
)
if
'_add_another'
in
request
.
form
:
return
redirect
(
self
.
get_url
(
'.create_view'
,
url
=
return_url
))
elif
'_continue_editing'
in
request
.
form
:
...
...
@@ -2012,7 +2012,7 @@ class BaseModelView(BaseView, ActionsMixin):
model
=
self
.
get_one
(
id
)
if
model
is
None
:
flash
(
gettext
(
'Record does not exist.'
))
flash
(
gettext
(
'Record does not exist.'
)
,
'error'
)
return
redirect
(
return_url
)
if
self
.
details_modal
and
request
.
args
.
get
(
'modal'
):
...
...
@@ -2045,12 +2045,12 @@ class BaseModelView(BaseView, ActionsMixin):
model
=
self
.
get_one
(
id
)
if
model
is
None
:
flash
(
gettext
(
'Record does not exist.'
))
flash
(
gettext
(
'Record does not exist.'
)
,
'error'
)
return
redirect
(
return_url
)
# message is flashed from within delete_model if it fails
if
self
.
delete_model
(
model
):
flash
(
gettext
(
'Record was successfully deleted.'
))
flash
(
gettext
(
'Record was successfully deleted.'
)
,
'success'
)
return
redirect
(
return_url
)
else
:
flash_errors
(
form
,
message
=
'Failed to delete record.
%(error)
s'
)
...
...
@@ -2100,7 +2100,7 @@ class BaseModelView(BaseView, ActionsMixin):
return_url
=
get_redirect_target
()
or
self
.
get_url
(
'.index_view'
)
if
not
self
.
can_export
or
(
export_type
not
in
self
.
export_types
):
flash
(
gettext
(
'Permission denied.'
))
flash
(
gettext
(
'Permission denied.'
)
,
'error'
)
return
redirect
(
return_url
)
if
export_type
==
'csv'
:
...
...
@@ -2154,7 +2154,7 @@ class BaseModelView(BaseView, ActionsMixin):
Exports a variety of formats using the tablib library.
"""
if
tablib
is
None
:
flash
(
gettext
(
'Tablib dependency not installed.'
))
flash
(
gettext
(
'Tablib dependency not installed.'
)
,
'error'
)
return
redirect
(
return_url
)
filename
=
self
.
get_export_name
(
export_type
)
...
...
@@ -2182,7 +2182,7 @@ class BaseModelView(BaseView, ActionsMixin):
response_data
=
getattr
(
ds
,
export_type
)
except
(
AttributeError
,
tablib
.
UnsupportedFormat
):
flash
(
gettext
(
'Export type "
%(type)
s not supported.'
,
type
=
export_type
))
type
=
export_type
)
,
'error'
)
return
redirect
(
return_url
)
return
Response
(
...
...
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