Beispiel #1
0
	def add_office(self,co,office):
		o = Office()
		officeValues = {'description':'description','is-hq':'is-headquarters'}
		# check to see if there is a description for the office
		if 'description' in office:
			o.description = office['description']
		# check to see if the office has an headquarters value
		if 'is-headquarters' in office:
			o.is_hq = office['is-headquarters']
		
		addressValues = {'addr_1':'street1','addr_2':'street2','city':'city','state_code':'state','postal_code':'postalCode','country_code':'country-code'}
		# check to see if there is an address value
		if 'address' in office:
			for k,v in addressValues.iteritems(): 
				if v in office['address']:
					setattr(o,k,office['address'][v])
					# o.k = office['address'][v]
			# o.addr_1 = office['address']['street1']
			# o.addr_2 = office['address']['street2']
			# o.city = office['address']['city']
			# o.state_code = office['address']['state']
			# o.postal_code = office['address']['postal-code']
			# o.country_code = office['address']['country-code']
		o.entity = co
		o.save()