23
23
24
24
from .fieldgenerator import MongoDefaultFormFieldGenerator
25
25
from .documentoptions import DocumentMetaWrapper
26
-
27
26
from .util import with_metaclass
28
27
29
28
@@ -48,9 +47,9 @@ def __init__(self, key, field):
48
47
49
48
self ._fields [key ] = field
50
49
51
- # don't care if anything gets marked on this
50
+ # We don't care if anything gets marked on this
52
51
# we do update a real field later though. That should
53
- # trigger the same thing on the real document though .
52
+ # trigger the same thing on the real document.
54
53
def _mark_as_changed (self , key ):
55
54
pass
56
55
@@ -59,8 +58,6 @@ def _save_iterator_file(field, uploaded_file, file_data=None):
59
58
Takes care of saving a file for a list field. Returns a Mongoengine
60
59
fileproxy object or the file field.
61
60
"""
62
- uploaded_file .seek (0 )
63
- filename = _get_unique_filename (uploaded_file .name )
64
61
fake_document = FakeDocument (field .name , field .field )
65
62
overwrote_instance = False
66
63
overwrote_key = False
@@ -79,7 +76,9 @@ def _save_iterator_file(field, uploaded_file, file_data=None):
79
76
80
77
if file_data .grid_id :
81
78
file_data .delete ()
82
-
79
+
80
+ uploaded_file .seek (0 )
81
+ filename = _get_unique_filename (uploaded_file .name )
83
82
file_data .put (uploaded_file , content_type = uploaded_file .content_type , filename = filename )
84
83
file_data .close ()
85
84
@@ -123,7 +122,7 @@ def construct_instance(form, instance, fields=None, exclude=None, ignore=None):
123
122
if isinstance (f , MapField ):
124
123
map_field = getattr (instance , f .name )
125
124
uploads = cleaned_data [f .name ]
126
- for key , uploaded_file in uploads .items ():
125
+ for key , uploaded_file in uploads .items ():
127
126
if uploaded_file is None :
128
127
continue
129
128
file_data = map_field .get (key , None )
0 commit comments