Commit aaa97c64 authored by Serge S. Koval's avatar Serge S. Koval

Extended file admin a bit.

parent f505933a
......@@ -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/>`_.
Kudos
-----
Some ideas were taken from the `Flask-Admin <https://github.com/wilsaj/flask-admin>`_ by Andy Wilson.
Examples
--------
......
......@@ -40,6 +40,7 @@
.. automethod:: FileAdmin.get_base_path
.. automethod:: FileAdmin.get_base_url
.. automethod:: FileAdmin.is_in_folder
.. automethod:: FileAdmin.save_file
Views
-----
......
......@@ -206,6 +206,17 @@ class FileAdmin(BaseView):
"""
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):
"""
Return prettified URL
......@@ -330,7 +341,7 @@ class FileAdmin(BaseView):
'error')
else:
try:
form.upload.file.save(filename)
self.save_file(filename, form.upload.file)
return redirect(self._get_dir_url('.index', path))
except Exception, ex:
flash('Failed to save file: %s' % ex)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment