@@ -220,20 +220,15 @@ def create_instance(username, xml_file, media_files,
220220 existing_instance_count = Instance .objects .filter (
221221 xml = xml , xform__user = xform .user ).count ()
222222
223- if existing_instance_count == 0 :
224- proceed_to_create_instance = True
225- else :
223+ if existing_instance_count > 0 :
226224 existing_instance = Instance .objects .filter (
227225 xml = xml , xform__user = xform .user )[0 ]
228- if existing_instance .xform and \
229- not existing_instance .xform .has_start_time :
230- proceed_to_create_instance = True
231- else :
226+ if not existing_instance .xform or \
227+ existing_instance .xform .has_start_time :
232228 # Ignore submission as a duplicate IFF
233229 # * a submission's XForm collects start time
234230 # * the submitted XML is an exact match with one that
235231 # has already been submitted for that user.
236- proceed_to_create_instance = False
237232 raise DuplicateInstance ()
238233
239234 # get new and depracated uuid's
@@ -249,12 +244,10 @@ def create_instance(username, xml_file, media_files,
249244 transaction .commit ()
250245 raise DuplicateInstance ()
251246
252- if proceed_to_create_instance :
253- instance = save_submission (xform , xml , media_files , new_uuid ,
254- submitted_by , status ,
255- date_created_override )
256- # commit all changes
257- transaction .commit ()
247+ instance = save_submission (xform , xml , media_files , new_uuid ,
248+ submitted_by , status , date_created_override )
249+ # commit all changes
250+ transaction .commit ()
258251
259252 return instance
260253 except Exception :
0 commit comments