#NEWLINE# def _testVolWithExistingLocations( self , site , address ) : #NEWLINE# #INDENT# '\n            Test a New Volunteer with existing Site &/or Home Address\n        ' #NEWLINE# db = current . db #NEWLINE# s3db = current . s3db #NEWLINE# gtable = s3db . gis_location #NEWLINE# ptable = s3db . pr_person #NEWLINE# record = Storage ( first_name = 'Test' , last_name = 'Person' ) #NEWLINE# person_id = ptable . insert ( ** record ) #NEWLINE# self . assertNotEqual ( person_id , None ) #NEWLINE# record [ 'id' ] = person_id #NEWLINE# s3db . update_super ( ptable , record ) #NEWLINE# s3db . onaccept ( ptable , record , method = 'create' ) #NEWLINE# pe_id = record [ 'pe_id' ] #NEWLINE# if address : #NEWLINE# #INDENT# record = Storage ( name = 'Test Address Location' ) #NEWLINE# address_location_id = gtable . insert ( ** human_resource_id ) #NEWLINE# self . assertNotEqual ( address_location_id , None ) #NEWLINE# record [ 'id' ] = address_location_id #NEWLINE# s3db . onaccept ( gtable , record , method = 'create' ) #NEWLINE# atable = s3db . pr_address #NEWLINE# record = Storage ( pe_id = pe_id , type = 1 , location_id = address_location_id ) #NEWLINE# address_id = atable . insert ( ** record ) #NEWLINE# self . assertNotEqual ( address_id , None ) #NEWLINE# record [ 'id' ] = address_id #NEWLINE# s3db . onaccept ( atable , record , method = 'create' ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# address_location_id = None #NEWLINE# #UNINDENT# if site : #NEWLINE# #INDENT# record = Storage ( name = 'Test Site Location' ) #NEWLINE# site_location_id = gtable . insert ( ** record ) #NEWLINE# self . assertNotEqual ( site_location_id , None ) #NEWLINE# record [ 'id' ] = site_location_id #NEWLINE# s3db . onaccept ( gtable , record , method = 'create' ) #NEWLINE# otable = s3db . org_office #NEWLINE# record = Storage ( name = 'Test Office' , location_id = site_location_id ) #NEWLINE# office_id = otable . insert ( ** record ) #NEWLINE# self . assertNotEqual ( office_id , None ) #NEWLINE# record [ 'id' ] = office_id #NEWLINE# s3db . update_super ( otable , record ) #NEWLINE# s3db . onaccept ( otable , record , method = 'create' ) #NEWLINE# site_id = record [ 'site_id' ] #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# site_location_id = site_id = None #NEWLINE# #UNINDENT# htable = s3db . hrm_human_resource #NEWLINE# record = Storage ( person_id = person_id , type = 2 , site_id = site_id ) #NEWLINE# human_resource_id = htable . insert ( ** record ) #NEWLINE# self . assertNotEqual ( human_resource_id , None ) #NEWLINE# record [ 'id' ] = human_resource_id #NEWLINE# s3db . update_super ( htable , record ) #NEWLINE# s3db . onaccept ( htable , record , method = 'create' ) #NEWLINE# row = db ( ( htable . id == human_resource_id ) ) . select ( htable . location_id , limitby = ( 0 , 1 ) ) . first ( ) #NEWLINE# self . assertNotEqual ( row , None ) #NEWLINE# return ( row , address_location_id , site_location_id )