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
64b90fad
Commit
64b90fad
authored
Feb 25, 2016
by
Tom Kedem
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fixes #1131 - broken action redirect in FileAdmin
parent
97cc3252
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
25 additions
and
25 deletions
+25
-25
__init__.py
flask_admin/contrib/fileadmin/__init__.py
+17
-17
list.html
flask_admin/templates/bootstrap2/admin/file/list.html
+4
-4
list.html
flask_admin/templates/bootstrap3/admin/file/list.html
+4
-4
No files found.
flask_admin/contrib/fileadmin/__init__.py
View file @
64b90fad
...
@@ -698,7 +698,7 @@ class BaseFileAdmin(BaseView, ActionsMixin):
...
@@ -698,7 +698,7 @@ class BaseFileAdmin(BaseView, ActionsMixin):
@
expose
(
'/'
)
@
expose
(
'/'
)
@
expose
(
'/b/<path:path>'
)
@
expose
(
'/b/<path:path>'
)
def
index
(
self
,
path
=
None
):
def
index
_view
(
self
,
path
=
None
):
"""
"""
Index view method
Index view method
...
@@ -714,7 +714,7 @@ class BaseFileAdmin(BaseView, ActionsMixin):
...
@@ -714,7 +714,7 @@ class BaseFileAdmin(BaseView, ActionsMixin):
base_path
,
directory
,
path
=
self
.
_normalize_path
(
path
)
base_path
,
directory
,
path
=
self
.
_normalize_path
(
path
)
if
not
self
.
is_accessible_path
(
path
):
if
not
self
.
is_accessible_path
(
path
):
flash
(
gettext
(
'Permission denied.'
),
'error'
)
flash
(
gettext
(
'Permission denied.'
),
'error'
)
return
redirect
(
self
.
_get_dir_url
(
'.index'
))
return
redirect
(
self
.
_get_dir_url
(
'.index
_view
'
))
# Get directory listing
# Get directory listing
items
=
[]
items
=
[]
...
@@ -771,11 +771,11 @@ class BaseFileAdmin(BaseView, ActionsMixin):
...
@@ -771,11 +771,11 @@ class BaseFileAdmin(BaseView, ActionsMixin):
if
not
self
.
can_upload
:
if
not
self
.
can_upload
:
flash
(
gettext
(
'File uploading is disabled.'
),
'error'
)
flash
(
gettext
(
'File uploading is disabled.'
),
'error'
)
return
redirect
(
self
.
_get_dir_url
(
'.index'
,
path
))
return
redirect
(
self
.
_get_dir_url
(
'.index
_view
'
,
path
))
if
not
self
.
is_accessible_path
(
path
):
if
not
self
.
is_accessible_path
(
path
):
flash
(
gettext
(
'Permission denied.'
),
'error'
)
flash
(
gettext
(
'Permission denied.'
),
'error'
)
return
redirect
(
self
.
_get_dir_url
(
'.index'
))
return
redirect
(
self
.
_get_dir_url
(
'.index
_view
'
))
form
=
self
.
upload_form
()
form
=
self
.
upload_form
()
if
self
.
validate_form
(
form
):
if
self
.
validate_form
(
form
):
...
@@ -783,7 +783,7 @@ class BaseFileAdmin(BaseView, ActionsMixin):
...
@@ -783,7 +783,7 @@ class BaseFileAdmin(BaseView, ActionsMixin):
self
.
_save_form_files
(
directory
,
path
,
form
)
self
.
_save_form_files
(
directory
,
path
,
form
)
flash
(
gettext
(
'Successfully saved file:
%(name)
s'
,
flash
(
gettext
(
'Successfully saved file:
%(name)
s'
,
name
=
form
.
upload
.
data
.
filename
))
name
=
form
.
upload
.
data
.
filename
))
return
redirect
(
self
.
_get_dir_url
(
'.index'
,
path
))
return
redirect
(
self
.
_get_dir_url
(
'.index
_view
'
,
path
))
except
Exception
as
ex
:
except
Exception
as
ex
:
flash
(
gettext
(
'Failed to save file:
%(error)
s'
,
error
=
ex
),
'error'
)
flash
(
gettext
(
'Failed to save file:
%(error)
s'
,
error
=
ex
),
'error'
)
...
@@ -812,7 +812,7 @@ class BaseFileAdmin(BaseView, ActionsMixin):
...
@@ -812,7 +812,7 @@ class BaseFileAdmin(BaseView, ActionsMixin):
# backward compatibility with base_url
# backward compatibility with base_url
base_url
=
self
.
get_base_url
()
base_url
=
self
.
get_base_url
()
if
base_url
:
if
base_url
:
base_url
=
urljoin
(
self
.
get_url
(
'.index'
),
base_url
)
base_url
=
urljoin
(
self
.
get_url
(
'.index
_view
'
),
base_url
)
return
redirect
(
urljoin
(
base_url
,
path
))
return
redirect
(
urljoin
(
base_url
,
path
))
return
self
.
storage
.
send_file
(
directory
)
return
self
.
storage
.
send_file
(
directory
)
...
@@ -829,7 +829,7 @@ class BaseFileAdmin(BaseView, ActionsMixin):
...
@@ -829,7 +829,7 @@ class BaseFileAdmin(BaseView, ActionsMixin):
# Get path and verify if it is valid
# Get path and verify if it is valid
base_path
,
directory
,
path
=
self
.
_normalize_path
(
path
)
base_path
,
directory
,
path
=
self
.
_normalize_path
(
path
)
dir_url
=
self
.
_get_dir_url
(
'.index'
,
path
)
dir_url
=
self
.
_get_dir_url
(
'.index
_view
'
,
path
)
if
not
self
.
can_mkdir
:
if
not
self
.
can_mkdir
:
flash
(
gettext
(
'Directory creation is disabled.'
),
'error'
)
flash
(
gettext
(
'Directory creation is disabled.'
),
'error'
)
...
@@ -837,7 +837,7 @@ class BaseFileAdmin(BaseView, ActionsMixin):
...
@@ -837,7 +837,7 @@ class BaseFileAdmin(BaseView, ActionsMixin):
if
not
self
.
is_accessible_path
(
path
):
if
not
self
.
is_accessible_path
(
path
):
flash
(
gettext
(
'Permission denied.'
),
'error'
)
flash
(
gettext
(
'Permission denied.'
),
'error'
)
return
redirect
(
self
.
_get_dir_url
(
'.index'
))
return
redirect
(
self
.
_get_dir_url
(
'.index
_view
'
))
form
=
self
.
name_form
()
form
=
self
.
name_form
()
...
@@ -876,9 +876,9 @@ class BaseFileAdmin(BaseView, ActionsMixin):
...
@@ -876,9 +876,9 @@ class BaseFileAdmin(BaseView, ActionsMixin):
path
=
form
.
path
.
data
path
=
form
.
path
.
data
if
path
:
if
path
:
return_url
=
self
.
_get_dir_url
(
'.index'
,
op
.
dirname
(
path
))
return_url
=
self
.
_get_dir_url
(
'.index
_view
'
,
op
.
dirname
(
path
))
else
:
else
:
return_url
=
self
.
get_url
(
'.index'
)
return_url
=
self
.
get_url
(
'.index
_view
'
)
if
self
.
validate_form
(
form
):
if
self
.
validate_form
(
form
):
# Get path and verify if it is valid
# Get path and verify if it is valid
...
@@ -890,7 +890,7 @@ class BaseFileAdmin(BaseView, ActionsMixin):
...
@@ -890,7 +890,7 @@ class BaseFileAdmin(BaseView, ActionsMixin):
if
not
self
.
is_accessible_path
(
path
):
if
not
self
.
is_accessible_path
(
path
):
flash
(
gettext
(
'Permission denied.'
),
'error'
)
flash
(
gettext
(
'Permission denied.'
),
'error'
)
return
redirect
(
self
.
_get_dir_url
(
'.index'
))
return
redirect
(
self
.
_get_dir_url
(
'.index
_view
'
))
if
self
.
storage
.
is_dir
(
full_path
):
if
self
.
storage
.
is_dir
(
full_path
):
if
not
self
.
can_delete_dirs
:
if
not
self
.
can_delete_dirs
:
...
@@ -927,9 +927,9 @@ class BaseFileAdmin(BaseView, ActionsMixin):
...
@@ -927,9 +927,9 @@ class BaseFileAdmin(BaseView, ActionsMixin):
if
path
:
if
path
:
base_path
,
full_path
,
path
=
self
.
_normalize_path
(
path
)
base_path
,
full_path
,
path
=
self
.
_normalize_path
(
path
)
return_url
=
self
.
_get_dir_url
(
'.index'
,
op
.
dirname
(
path
))
return_url
=
self
.
_get_dir_url
(
'.index
_view
'
,
op
.
dirname
(
path
))
else
:
else
:
return
redirect
(
self
.
get_url
(
'.index'
))
return
redirect
(
self
.
get_url
(
'.index
_view
'
))
if
not
self
.
can_rename
:
if
not
self
.
can_rename
:
flash
(
gettext
(
'Renaming is disabled.'
),
'error'
)
flash
(
gettext
(
'Renaming is disabled.'
),
'error'
)
...
@@ -937,7 +937,7 @@ class BaseFileAdmin(BaseView, ActionsMixin):
...
@@ -937,7 +937,7 @@ class BaseFileAdmin(BaseView, ActionsMixin):
if
not
self
.
is_accessible_path
(
path
):
if
not
self
.
is_accessible_path
(
path
):
flash
(
gettext
(
'Permission denied.'
),
'error'
)
flash
(
gettext
(
'Permission denied.'
),
'error'
)
return
redirect
(
self
.
_get_dir_url
(
'.index'
))
return
redirect
(
self
.
_get_dir_url
(
'.index
_view
'
))
if
not
self
.
storage
.
path_exists
(
full_path
):
if
not
self
.
storage
.
path_exists
(
full_path
):
flash
(
gettext
(
'Path does not exist.'
),
'error'
)
flash
(
gettext
(
'Path does not exist.'
),
'error'
)
...
@@ -978,7 +978,7 @@ class BaseFileAdmin(BaseView, ActionsMixin):
...
@@ -978,7 +978,7 @@ class BaseFileAdmin(BaseView, ActionsMixin):
path
=
request
.
args
.
getlist
(
'path'
)
path
=
request
.
args
.
getlist
(
'path'
)
if
not
path
:
if
not
path
:
return
redirect
(
self
.
get_url
(
'.index'
))
return
redirect
(
self
.
get_url
(
'.index
_view
'
))
if
len
(
path
)
>
1
:
if
len
(
path
)
>
1
:
next_url
=
self
.
get_url
(
'.edit'
,
path
=
path
[
1
:])
next_url
=
self
.
get_url
(
'.edit'
,
path
=
path
[
1
:])
...
@@ -989,9 +989,9 @@ class BaseFileAdmin(BaseView, ActionsMixin):
...
@@ -989,9 +989,9 @@ class BaseFileAdmin(BaseView, ActionsMixin):
if
not
self
.
is_accessible_path
(
path
)
or
not
self
.
is_file_editable
(
path
):
if
not
self
.
is_accessible_path
(
path
)
or
not
self
.
is_file_editable
(
path
):
flash
(
gettext
(
'Permission denied.'
),
'error'
)
flash
(
gettext
(
'Permission denied.'
),
'error'
)
return
redirect
(
self
.
_get_dir_url
(
'.index'
))
return
redirect
(
self
.
_get_dir_url
(
'.index
_view
'
))
dir_url
=
self
.
_get_dir_url
(
'.index'
,
op
.
dirname
(
path
))
dir_url
=
self
.
_get_dir_url
(
'.index
_view
'
,
op
.
dirname
(
path
))
next_url
=
next_url
or
dir_url
next_url
=
next_url
or
dir_url
form
=
self
.
edit_form
()
form
=
self
.
edit_form
()
...
...
flask_admin/templates/bootstrap2/admin/file/list.html
View file @
64b90fad
...
@@ -6,16 +6,16 @@
...
@@ -6,16 +6,16 @@
{% block breadcrums %}
{% block breadcrums %}
<ul
class=
"breadcrumb"
>
<ul
class=
"breadcrumb"
>
<li>
<li>
<a
href=
"{{ get_dir_url('.index', path=None) }}"
>
{{ _gettext('Root') }}
</a>
<a
href=
"{{ get_dir_url('.index
_view
', path=None) }}"
>
{{ _gettext('Root') }}
</a>
</li>
</li>
{% for name, path in breadcrumbs[:-1] %}
{% for name, path in breadcrumbs[:-1] %}
<li>
<li>
<span
class=
"divider"
>
/
</span><a
href=
"{{ get_dir_url('.index', path=path) }}"
>
{{ name }}
</a>
<span
class=
"divider"
>
/
</span><a
href=
"{{ get_dir_url('.index
_view
', path=path) }}"
>
{{ name }}
</a>
</li>
</li>
{% endfor %}
{% endfor %}
{% if breadcrumbs %}
{% if breadcrumbs %}
<li>
<li>
<span
class=
"divider"
>
/
</span><a
href=
"{{ get_dir_url('.index', path=breadcrumbs[-1][1]) }}"
>
{{ breadcrumbs[-1][0] }}
</a>
<span
class=
"divider"
>
/
</span><a
href=
"{{ get_dir_url('.index
_view
', path=breadcrumbs[-1][1]) }}"
>
{{ breadcrumbs[-1][0] }}
</a>
</li>
</li>
{% endif %}
{% endif %}
</ul>
</ul>
...
@@ -85,7 +85,7 @@
...
@@ -85,7 +85,7 @@
</td>
</td>
{% if is_dir %}
{% if is_dir %}
<td
colspan=
"2"
>
<td
colspan=
"2"
>
<a
href=
"{{ get_dir_url('.index', path)|safe }}"
>
<a
href=
"{{ get_dir_url('.index
_view
', path)|safe }}"
>
<i
class=
"fa fa-folder-o icon-folder-close"
></i>
<span>
{{ name }}
</span>
<i
class=
"fa fa-folder-o icon-folder-close"
></i>
<span>
{{ name }}
</span>
</a>
</a>
</td>
</td>
...
...
flask_admin/templates/bootstrap3/admin/file/list.html
View file @
64b90fad
...
@@ -6,16 +6,16 @@
...
@@ -6,16 +6,16 @@
{% block breadcrums %}
{% block breadcrums %}
<ul
class=
"breadcrumb"
>
<ul
class=
"breadcrumb"
>
<li>
<li>
<a
href=
"{{ get_dir_url('.index', path=None) }}"
>
{{ _gettext('Root') }}
</a>
<a
href=
"{{ get_dir_url('.index
_view
', path=None) }}"
>
{{ _gettext('Root') }}
</a>
</li>
</li>
{% for name, path in breadcrumbs[:-1] %}
{% for name, path in breadcrumbs[:-1] %}
<li>
<li>
<a
href=
"{{ get_dir_url('.index', path=path) }}"
>
{{ name }}
</a>
<a
href=
"{{ get_dir_url('.index
_view
', path=path) }}"
>
{{ name }}
</a>
</li>
</li>
{% endfor %}
{% endfor %}
{% if breadcrumbs %}
{% if breadcrumbs %}
<li>
<li>
<a
href=
"{{ get_dir_url('.index', path=breadcrumbs[-1][1]) }}"
>
{{ breadcrumbs[-1][0] }}
</a>
<a
href=
"{{ get_dir_url('.index
_view
', path=breadcrumbs[-1][1]) }}"
>
{{ breadcrumbs[-1][0] }}
</a>
</li>
</li>
{% endif %}
{% endif %}
</ul>
</ul>
...
@@ -85,7 +85,7 @@
...
@@ -85,7 +85,7 @@
</td>
</td>
{% if is_dir %}
{% if is_dir %}
<td
colspan=
"2"
>
<td
colspan=
"2"
>
<a
href=
"{{ get_dir_url('.index', path)|safe }}"
>
<a
href=
"{{ get_dir_url('.index
_view
', path)|safe }}"
>
<i
class=
"fa fa-folder-o glyphicon glyphicon-folder-close"
></i>
<span>
{{ name }}
</span>
<i
class=
"fa fa-folder-o glyphicon glyphicon-folder-close"
></i>
<span>
{{ name }}
</span>
</a>
</a>
</td>
</td>
...
...
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