#NEWLINE# def _handle_business_contact( business , org , contact_data ) : #NEWLINE# #INDENT# 'Update or create contact and update buisness.' #NEWLINE# from contacts.models import Contact , CONTACT_TYPES #NEWLINE# if ( not contact_data ) : #NEWLINE# #INDENT# return business #NEWLINE# #UNINDENT# contact_data = copy . deepcopy ( contact_data ) #NEWLINE# pk = contact_data . pop ( 'id' , None ) #NEWLINE# contact_data = copy . deepcopy ( contact_data ) #NEWLINE# contact_data [ 'contact_type' ] = convert_choice_data ( contact_data . get ( 'contact_type' ) , CONTACT_TYPES ) #NEWLINE# contact_data [ 'super_organization_id' ] = org . pk #NEWLINE# contact = None #NEWLINE# if pk : #NEWLINE# #INDENT# contact = Contact . objects . get ( pk = pk ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if contact_data : #NEWLINE# #INDENT# contact = Contact . objects . create ( ** contact_data ) #NEWLINE# #UNINDENT# #UNINDENT# if contact : #NEWLINE# #INDENT# contact . super_organization = org #NEWLINE# contact . save ( ) #NEWLINE# business . owner = contact #NEWLINE# business . save ( ) #NEWLINE# #UNINDENT# return pk