#NEWLINE# def get_registration_instance( self , custom_values = { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } ) : #NEWLINE# #INDENT# '\n        1. Checks to see if the registration form has been created alread.\n           If not, it loads it in.\n        2. Loads a registration instance.\n        ' #NEWLINE# registration_xforms = XForm . objects . filter ( title = 'registration' ) #NEWLINE# if ( registration_xforms . count ( ) == 0 ) : #NEWLINE# #INDENT# xf = self . create_registration_xform ( ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# xf = registration_xforms [ 0 ] #NEWLINE# #UNINDENT# values = { #NEWLINE# #INDENT# 'device_id' : '12345' , #NEWLINE# 'start' : '2011-01-01T09:50:06.966' , #NEWLINE# 'end' : '2011-01-01T09:53:22.965' , #NEWLINE# #UNINDENT# } #NEWLINE# if ( 'start' in custom_values ) : #NEWLINE# #INDENT# st = custom_values [ 'start' ] #NEWLINE# custom_values [ 'start' ] = st . strftime ( XFORM_TIME_FORMAT ) #NEWLINE# values [ 'end' ] = ( st + ONE_HOUR ) . strftime ( XFORM_TIME_FORMAT ) #NEWLINE# #UNINDENT# if ( 'end' in custom_values ) : #NEWLINE# #INDENT# custom_values [ 'end' ] = custom_values [ 'end' ] . strftime ( XFORM_TIME_FORMAT ) #NEWLINE# #UNINDENT# values . update ( custom_values ) #NEWLINE# reg_xform = _load_registration_survey_object ( ) #NEWLINE# reg_instance = reg_xform . instantiate ( ) #NEWLINE# reg_instance . _id = xf . id_string #NEWLINE# for ( k , v ) in values . items ( ) : #NEWLINE# #INDENT# reg_instance . answer ( name = k , value = v ) #NEWLINE# #UNINDENT# instance_xml = reg_instance . to_xml ( ) #NEWLINE# return Instance ( xml = instance_xml )