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
30c3f537
Commit
30c3f537
authored
Jun 14, 2013
by
Serge S. Koval
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed fileadmin
parent
f1a4f77f
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
13 additions
and
12 deletions
+13
-12
_compat.py
flask_admin/_compat.py
+4
-0
base.py
flask_admin/base.py
+1
-1
fileadmin.py
flask_admin/contrib/fileadmin.py
+8
-9
base.py
flask_admin/model/base.py
+0
-2
No files found.
flask_admin/_compat.py
View file @
30c3f537
...
@@ -30,7 +30,9 @@ if not PY2:
...
@@ -30,7 +30,9 @@ if not PY2:
return
str
(
text
)
return
str
(
text
)
# Various tools
from
functools
import
reduce
from
functools
import
reduce
from
urllib.parse
import
urljoin
else
:
else
:
unicode_type
=
unicode
unicode_type
=
unicode
text_type
=
unicode
text_type
=
unicode
...
@@ -44,7 +46,9 @@ else:
...
@@ -44,7 +46,9 @@ else:
def
as_unicode
(
text
):
def
as_unicode
(
text
):
return
unicode
(
text
)
return
unicode
(
text
)
# Helpers
reduce
=
__builtins__
[
'reduce'
]
reduce
=
__builtins__
[
'reduce'
]
from
urlparse
import
urljoin
def
with_metaclass
(
meta
,
*
bases
):
def
with_metaclass
(
meta
,
*
bases
):
...
...
flask_admin/base.py
View file @
30c3f537
...
@@ -468,7 +468,7 @@ class Admin(object):
...
@@ -468,7 +468,7 @@ class Admin(object):
self
.
locale_selector_func
=
None
self
.
locale_selector_func
=
None
# Register with application
# Register with application
if
app
:
if
app
is
not
None
:
self
.
_init_extension
()
self
.
_init_extension
()
def
add_view
(
self
,
view
):
def
add_view
(
self
,
view
):
...
...
flask_admin/contrib/fileadmin.py
View file @
30c3f537
import
os
import
os
import
os.path
as
op
import
os.path
as
op
import
platform
import
platform
import
urlparse
import
re
import
re
import
shutil
import
shutil
...
@@ -12,10 +11,10 @@ from flask import flash, url_for, redirect, abort, request
...
@@ -12,10 +11,10 @@ from flask import flash, url_for, redirect, abort, request
from
wtforms
import
fields
,
validators
from
wtforms
import
fields
,
validators
from
flask.ext.admin
import
form
,
helpers
,
_compat
from
flask.ext.admin.base
import
BaseView
,
expose
from
flask.ext.admin.base
import
BaseView
,
expose
from
flask.ext.admin.actions
import
action
,
ActionsMixin
from
flask.ext.admin.actions
import
action
,
ActionsMixin
from
flask.ext.admin.babel
import
gettext
,
lazy_gettext
from
flask.ext.admin.babel
import
gettext
,
lazy_gettext
from
flask.ext.admin
import
form
,
helpers
class
NameForm
(
form
.
BaseForm
):
class
NameForm
(
form
.
BaseForm
):
...
@@ -313,7 +312,7 @@ class FileAdmin(BaseView, ActionsMixin):
...
@@ -313,7 +312,7 @@ class FileAdmin(BaseView, ActionsMixin):
return
url_for
(
".edit"
,
path
=
path
)
return
url_for
(
".edit"
,
path
=
path
)
else
:
else
:
base_url
=
self
.
get_base_url
()
base_url
=
self
.
get_base_url
()
return
urlparse
.
urljoin
(
base_url
,
path
)
return
_compat
.
urljoin
(
base_url
,
path
)
def
_normalize_path
(
self
,
path
):
def
_normalize_path
(
self
,
path
):
"""
"""
...
@@ -488,7 +487,7 @@ class FileAdmin(BaseView, ActionsMixin):
...
@@ -488,7 +487,7 @@ class FileAdmin(BaseView, ActionsMixin):
self
.
save_file
(
filename
,
form
.
upload
.
data
)
self
.
save_file
(
filename
,
form
.
upload
.
data
)
self
.
on_file_upload
(
directory
,
path
,
filename
)
self
.
on_file_upload
(
directory
,
path
,
filename
)
return
redirect
(
self
.
_get_dir_url
(
'.index'
,
path
))
return
redirect
(
self
.
_get_dir_url
(
'.index'
,
path
))
except
Exception
,
ex
:
except
Exception
as
ex
:
flash
(
gettext
(
'Failed to save file:
%(error)
s'
,
error
=
ex
))
flash
(
gettext
(
'Failed to save file:
%(error)
s'
,
error
=
ex
))
return
self
.
render
(
self
.
upload_template
,
form
=
form
)
return
self
.
render
(
self
.
upload_template
,
form
=
form
)
...
@@ -518,7 +517,7 @@ class FileAdmin(BaseView, ActionsMixin):
...
@@ -518,7 +517,7 @@ class FileAdmin(BaseView, ActionsMixin):
os
.
mkdir
(
op
.
join
(
directory
,
form
.
name
.
data
))
os
.
mkdir
(
op
.
join
(
directory
,
form
.
name
.
data
))
self
.
on_mkdir
(
directory
,
form
.
name
.
data
)
self
.
on_mkdir
(
directory
,
form
.
name
.
data
)
return
redirect
(
dir_url
)
return
redirect
(
dir_url
)
except
Exception
,
ex
:
except
Exception
as
ex
:
flash
(
gettext
(
'Failed to create directory:
%(error)
s'
,
ex
),
'error'
)
flash
(
gettext
(
'Failed to create directory:
%(error)
s'
,
ex
),
'error'
)
return
self
.
render
(
self
.
mkdir_template
,
return
self
.
render
(
self
.
mkdir_template
,
...
@@ -553,14 +552,14 @@ class FileAdmin(BaseView, ActionsMixin):
...
@@ -553,14 +552,14 @@ class FileAdmin(BaseView, ActionsMixin):
shutil
.
rmtree
(
full_path
)
shutil
.
rmtree
(
full_path
)
self
.
on_directory_delete
(
full_path
,
path
)
self
.
on_directory_delete
(
full_path
,
path
)
flash
(
gettext
(
'Directory "
%
s" was successfully deleted.'
%
path
))
flash
(
gettext
(
'Directory "
%
s" was successfully deleted.'
%
path
))
except
Exception
,
ex
:
except
Exception
as
ex
:
flash
(
gettext
(
'Failed to delete directory:
%(error)
s'
,
error
=
ex
),
'error'
)
flash
(
gettext
(
'Failed to delete directory:
%(error)
s'
,
error
=
ex
),
'error'
)
else
:
else
:
try
:
try
:
os
.
remove
(
full_path
)
os
.
remove
(
full_path
)
self
.
on_file_delete
(
full_path
,
path
)
self
.
on_file_delete
(
full_path
,
path
)
flash
(
gettext
(
'File "
%(name)
s" was successfully deleted.'
,
name
=
path
))
flash
(
gettext
(
'File "
%(name)
s" was successfully deleted.'
,
name
=
path
))
except
Exception
,
ex
:
except
Exception
as
ex
:
flash
(
gettext
(
'Failed to delete file:
%(name)
s'
,
name
=
ex
),
'error'
)
flash
(
gettext
(
'Failed to delete file:
%(name)
s'
,
name
=
ex
),
'error'
)
return
redirect
(
return_url
)
return
redirect
(
return_url
)
...
@@ -598,7 +597,7 @@ class FileAdmin(BaseView, ActionsMixin):
...
@@ -598,7 +597,7 @@ class FileAdmin(BaseView, ActionsMixin):
flash
(
gettext
(
'Successfully renamed "
%(src)
s" to "
%(dst)
s"'
,
flash
(
gettext
(
'Successfully renamed "
%(src)
s" to "
%(dst)
s"'
,
src
=
op
.
basename
(
path
),
src
=
op
.
basename
(
path
),
dst
=
filename
))
dst
=
filename
))
except
Exception
,
ex
:
except
Exception
as
ex
:
flash
(
gettext
(
'Failed to rename:
%(error)
s'
,
error
=
ex
),
'error'
)
flash
(
gettext
(
'Failed to rename:
%(error)
s'
,
error
=
ex
),
'error'
)
return
redirect
(
return_url
)
return
redirect
(
return_url
)
...
@@ -683,7 +682,7 @@ class FileAdmin(BaseView, ActionsMixin):
...
@@ -683,7 +682,7 @@ class FileAdmin(BaseView, ActionsMixin):
try
:
try
:
os
.
remove
(
full_path
)
os
.
remove
(
full_path
)
flash
(
gettext
(
'File "
%(name)
s" was successfully deleted.'
,
name
=
path
))
flash
(
gettext
(
'File "
%(name)
s" was successfully deleted.'
,
name
=
path
))
except
Exception
,
ex
:
except
Exception
as
ex
:
flash
(
gettext
(
'Failed to delete file:
%(name)
s'
,
name
=
ex
),
'error'
)
flash
(
gettext
(
'Failed to delete file:
%(name)
s'
,
name
=
ex
),
'error'
)
@
action
(
'edit'
,
lazy_gettext
(
'Edit'
))
@
action
(
'edit'
,
lazy_gettext
(
'Edit'
))
...
...
flask_admin/model/base.py
View file @
30c3f537
...
@@ -647,8 +647,6 @@ class BaseModelView(BaseView, ActionsMixin):
...
@@ -647,8 +647,6 @@ class BaseModelView(BaseView, ActionsMixin):
else
:
else
:
return
self
.
column_default_sort
,
False
return
self
.
column_default_sort
,
False
return
field
,
direction
return
None
return
None
# Database-related API
# Database-related API
...
...
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