flask.ext.superadmin.contrib.fileadmin
¶
-
class
flask.ext.superadmin.contrib.fileadmin.
FileAdmin
(base_path, base_url, name=None, category=None, endpoint=None, url=None)[source]¶ Simple file-management interface.
Requires two parameters:
- path
- Path to the directory which will be managed
- url
- Base URL for the directory. Will be used to generate static links to the files.
Sample usage:
admin = Admin() path = op.join(op.dirname(__file__), 'static') admin.add_view(FileAdmin(path, '/static/', name='Static Files')) admin.setup_app(app)
-
can_upload
= True¶ Is file upload allowed.
-
can_delete
= True¶ Is file deletion allowed.
-
can_delete_dirs
= True¶ Is recursive directory deletion is allowed.
-
can_mkdir
= True¶ Is directory creation allowed.
-
can_rename
= True¶ Is file and directory renaming allowed.
-
allowed_extensions
= None¶ List of allowed extensions for uploads, in lower case.
Example:
class MyAdmin(FileAdmin): allowed_extensions = ('swf', 'jpg', 'gif', 'png')
-
list_template
= 'admin/file/list.html'¶ File list template
-
upload_template
= 'admin/file/form.html'¶ File upload template
-
mkdir_template
= 'admin/file/form.html'¶ Directory creation (mkdir) template
-
rename_template
= 'admin/file/rename.html'¶ Rename template
-
get_base_path
()[source]¶ Return base path. Override to customize behavior (per-user directories, etc)
-
index
(*args, **kwargs)[source]¶ Index view method
- path
- Optional directory path. If not provided, will use base directory
-
is_accessible_path
(path)[source]¶ Verify if path is accessible for current user.
Override to customize behavior.
- path
- Relative path to the root
-
is_file_allowed
(filename)[source]¶ Verify if file can be uploaded.
Override to customize behavior.
- filename
- Source file name
-
mkdir
(*args, **kwargs)[source]¶ Directory creation view method
- path
- Optional directory path. If not provided, will use base directory