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
aaa97c64
Commit
aaa97c64
authored
Mar 22, 2012
by
Serge S. Koval
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Extended file admin a bit.
parent
f505933a
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
18 additions
and
1 deletion
+18
-1
README.rst
README.rst
+5
-0
mod_ext_fileadmin.rst
doc/mod_ext_fileadmin.rst
+1
-0
fileadmin.py
flask_adminex/ext/fileadmin.py
+12
-1
No files found.
README.rst
View file @
aaa97c64
...
@@ -35,6 +35,11 @@ Flask-AdminEx is extensively documented, you can find documentation `here <http:
...
@@ -35,6 +35,11 @@ Flask-AdminEx is extensively documented, you can find documentation `here <http:
Flask-AdminEx is built with help of `Twitter Bootstrap <http://twitter.github.com/bootstrap/>`_ and `Chosen <http://harvesthq.github.com/chosen/>`_.
Flask-AdminEx is built with help of `Twitter Bootstrap <http://twitter.github.com/bootstrap/>`_ and `Chosen <http://harvesthq.github.com/chosen/>`_.
Kudos
-----
Some ideas were taken from the `Flask-Admin <https://github.com/wilsaj/flask-admin>`_ by Andy Wilson.
Examples
Examples
--------
--------
...
...
doc/mod_ext_fileadmin.rst
View file @
aaa97c64
...
@@ -40,6 +40,7 @@
...
@@ -40,6 +40,7 @@
.. automethod:: FileAdmin.get_base_path
.. automethod:: FileAdmin.get_base_path
.. automethod:: FileAdmin.get_base_url
.. automethod:: FileAdmin.get_base_url
.. automethod:: FileAdmin.is_in_folder
.. automethod:: FileAdmin.is_in_folder
.. automethod:: FileAdmin.save_file
Views
Views
-----
-----
...
...
flask_adminex/ext/fileadmin.py
View file @
aaa97c64
...
@@ -206,6 +206,17 @@ class FileAdmin(BaseView):
...
@@ -206,6 +206,17 @@ class FileAdmin(BaseView):
"""
"""
return
op
.
normpath
(
directory
)
.
startswith
(
base_path
)
return
op
.
normpath
(
directory
)
.
startswith
(
base_path
)
def
save_file
(
self
,
path
,
file_data
):
"""
Save uploaded file to the disk
`path`
Path to save to
`file_data`
Werkzeug `FileStorage` object
"""
file_data
.
save
(
path
)
def
_get_dir_url
(
self
,
endpoint
,
path
,
**
kwargs
):
def
_get_dir_url
(
self
,
endpoint
,
path
,
**
kwargs
):
"""
"""
Return prettified URL
Return prettified URL
...
@@ -330,7 +341,7 @@ class FileAdmin(BaseView):
...
@@ -330,7 +341,7 @@ class FileAdmin(BaseView):
'error'
)
'error'
)
else
:
else
:
try
:
try
:
form
.
upload
.
file
.
save
(
filenam
e
)
self
.
save_file
(
filename
,
form
.
upload
.
fil
e
)
return
redirect
(
self
.
_get_dir_url
(
'.index'
,
path
))
return
redirect
(
self
.
_get_dir_url
(
'.index'
,
path
))
except
Exception
,
ex
:
except
Exception
,
ex
:
flash
(
'Failed to save file:
%
s'
%
ex
)
flash
(
'Failed to save file:
%
s'
%
ex
)
...
...
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