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
f0b6cc20
Commit
f0b6cc20
authored
Feb 26, 2016
by
Serge S. Koval
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1215 from vToMy/fileadmin_action_fix
fixes #1131 - broken action redirect in FileAdmin
parents
97cc3252
846268be
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
32 additions
and
25 deletions
+32
-25
__init__.py
flask_admin/contrib/fileadmin/__init__.py
+24
-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 @
f0b6cc20
import
warnings
from
datetime
import
datetime
import
os
import
os.path
as
op
...
...
@@ -696,9 +697,15 @@ class BaseFileAdmin(BaseView, ActionsMixin):
breadcrumbs
.
append
((
n
,
self
.
_separator
.
join
(
accumulator
)))
return
breadcrumbs
@
expose
(
'/old_index'
)
@
expose
(
'/old_b/<path:path>'
)
def
index
(
self
,
path
=
None
):
warnings
.
warn
(
'deprecated: use index_view instead.'
,
DeprecationWarning
)
return
redirect
(
self
.
get_url
(
'.index_view'
,
path
=
path
))
@
expose
(
'/'
)
@
expose
(
'/b/<path:path>'
)
def
index
(
self
,
path
=
None
):
def
index
_view
(
self
,
path
=
None
):
"""
Index view method
...
...
@@ -714,7 +721,7 @@ class BaseFileAdmin(BaseView, ActionsMixin):
base_path
,
directory
,
path
=
self
.
_normalize_path
(
path
)
if
not
self
.
is_accessible_path
(
path
):
flash
(
gettext
(
'Permission denied.'
),
'error'
)
return
redirect
(
self
.
_get_dir_url
(
'.index'
))
return
redirect
(
self
.
_get_dir_url
(
'.index
_view
'
))
# Get directory listing
items
=
[]
...
...
@@ -771,11 +778,11 @@ class BaseFileAdmin(BaseView, ActionsMixin):
if
not
self
.
can_upload
:
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
):
flash
(
gettext
(
'Permission denied.'
),
'error'
)
return
redirect
(
self
.
_get_dir_url
(
'.index'
))
return
redirect
(
self
.
_get_dir_url
(
'.index
_view
'
))
form
=
self
.
upload_form
()
if
self
.
validate_form
(
form
):
...
...
@@ -783,7 +790,7 @@ class BaseFileAdmin(BaseView, ActionsMixin):
self
.
_save_form_files
(
directory
,
path
,
form
)
flash
(
gettext
(
'Successfully saved file:
%(name)
s'
,
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
:
flash
(
gettext
(
'Failed to save file:
%(error)
s'
,
error
=
ex
),
'error'
)
...
...
@@ -812,7 +819,7 @@ class BaseFileAdmin(BaseView, ActionsMixin):
# backward compatibility with base_url
base_url
=
self
.
get_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
self
.
storage
.
send_file
(
directory
)
...
...
@@ -829,7 +836,7 @@ class BaseFileAdmin(BaseView, ActionsMixin):
# Get path and verify if it is valid
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
:
flash
(
gettext
(
'Directory creation is disabled.'
),
'error'
)
...
...
@@ -837,7 +844,7 @@ class BaseFileAdmin(BaseView, ActionsMixin):
if
not
self
.
is_accessible_path
(
path
):
flash
(
gettext
(
'Permission denied.'
),
'error'
)
return
redirect
(
self
.
_get_dir_url
(
'.index'
))
return
redirect
(
self
.
_get_dir_url
(
'.index
_view
'
))
form
=
self
.
name_form
()
...
...
@@ -876,9 +883,9 @@ class BaseFileAdmin(BaseView, ActionsMixin):
path
=
form
.
path
.
data
if
path
:
return_url
=
self
.
_get_dir_url
(
'.index'
,
op
.
dirname
(
path
))
return_url
=
self
.
_get_dir_url
(
'.index
_view
'
,
op
.
dirname
(
path
))
else
:
return_url
=
self
.
get_url
(
'.index'
)
return_url
=
self
.
get_url
(
'.index
_view
'
)
if
self
.
validate_form
(
form
):
# Get path and verify if it is valid
...
...
@@ -890,7 +897,7 @@ class BaseFileAdmin(BaseView, ActionsMixin):
if
not
self
.
is_accessible_path
(
path
):
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
not
self
.
can_delete_dirs
:
...
...
@@ -927,9 +934,9 @@ class BaseFileAdmin(BaseView, ActionsMixin):
if
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
:
return
redirect
(
self
.
get_url
(
'.index'
))
return
redirect
(
self
.
get_url
(
'.index
_view
'
))
if
not
self
.
can_rename
:
flash
(
gettext
(
'Renaming is disabled.'
),
'error'
)
...
...
@@ -937,7 +944,7 @@ class BaseFileAdmin(BaseView, ActionsMixin):
if
not
self
.
is_accessible_path
(
path
):
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
):
flash
(
gettext
(
'Path does not exist.'
),
'error'
)
...
...
@@ -978,7 +985,7 @@ class BaseFileAdmin(BaseView, ActionsMixin):
path
=
request
.
args
.
getlist
(
'path'
)
if
not
path
:
return
redirect
(
self
.
get_url
(
'.index'
))
return
redirect
(
self
.
get_url
(
'.index
_view
'
))
if
len
(
path
)
>
1
:
next_url
=
self
.
get_url
(
'.edit'
,
path
=
path
[
1
:])
...
...
@@ -989,9 +996,9 @@ class BaseFileAdmin(BaseView, ActionsMixin):
if
not
self
.
is_accessible_path
(
path
)
or
not
self
.
is_file_editable
(
path
):
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
form
=
self
.
edit_form
()
...
...
flask_admin/templates/bootstrap2/admin/file/list.html
View file @
f0b6cc20
...
...
@@ -6,16 +6,16 @@
{% block breadcrums %}
<ul
class=
"breadcrumb"
>
<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>
{% for name, path in breadcrumbs[:-1] %}
<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>
{% endfor %}
{% if breadcrumbs %}
<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>
{% endif %}
</ul>
...
...
@@ -85,7 +85,7 @@
</td>
{% if is_dir %}
<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>
</a>
</td>
...
...
flask_admin/templates/bootstrap3/admin/file/list.html
View file @
f0b6cc20
...
...
@@ -6,16 +6,16 @@
{% block breadcrums %}
<ul
class=
"breadcrumb"
>
<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>
{% for name, path in breadcrumbs[:-1] %}
<li>
<a
href=
"{{ get_dir_url('.index', path=path) }}"
>
{{ name }}
</a>
<a
href=
"{{ get_dir_url('.index
_view
', path=path) }}"
>
{{ name }}
</a>
</li>
{% endfor %}
{% if breadcrumbs %}
<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>
{% endif %}
</ul>
...
...
@@ -85,7 +85,7 @@
</td>
{% if is_dir %}
<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>
</a>
</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