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
d6b827f4
Commit
d6b827f4
authored
Nov 13, 2013
by
Serge S. Koval
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #370 from BendingSpoons/master
Fix counterintuitive editing of MongoDB Documents with ImageField
parents
dc8d8fc3
44554259
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
1 deletion
+8
-1
fields.py
flask_admin/contrib/mongoengine/fields.py
+8
-1
No files found.
flask_admin/contrib/mongoengine/fields.py
View file @
d6b827f4
...
...
@@ -6,6 +6,13 @@ from wtforms.fields.core import _unset_value
from
.
import
widgets
def
is_empty
(
file_object
):
file_object
.
seek
(
0
)
first_char
=
file_object
.
read
(
1
)
file_object
.
seek
(
0
)
return
not
bool
(
first_char
)
class
ModelFormField
(
fields
.
FormField
):
"""
Customized ModelFormField for MongoEngine EmbeddedDocuments.
...
...
@@ -54,7 +61,7 @@ class MongoFileField(fields.FileField):
field
.
delete
()
return
if
isinstance
(
self
.
data
,
FileStorage
):
if
isinstance
(
self
.
data
,
FileStorage
)
and
not
is_empty
(
self
.
data
.
stream
)
:
if
not
field
.
grid_id
:
func
=
field
.
put
else
:
...
...
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