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()
Beispiel #2
0
 def add_office(self, entity, office):
     """ adds office and links it to entity """
     o = Office()
     o.entity = entity
     o.description = office["description"]
     o.addr_1 = office["address1"]
     o.addr_2 = office["address2"]
     o.zip_code = office["zip_code"]
     o.city = office["city"]
     o.state_code = office["state_code"]
     o.country_code = office["country_code"]
     if o.latitude:
         o.latitude = str(office["latitude"])
     if o.longitude:
         o.longitude = str(office["longitude"])
     o.save()
     sys.stdout.write(o.name().encode("utf8", "ignore") + " added\n")
Beispiel #3
0
	def addOffice(self,entity,office):
		""" adds office and links it to entity """
		o = Office()
		o.entity = entity
		o.description = office['description']
		o.addr_1 = office['address1']
		o.addr_2 = office['address2']
		o.zip_code = office['zip_code']
		o.city = office['city']
		o.state_code = office['state_code']
		o.country_code = office['country_code']
		if o.latitude:
			o.latitude = str(office['latitude'])
		if o.longitude:
			o.longitude = str(office['longitude'])
		o.save()
		self.stdout.write(o.name().encode('utf8','ignore') + " added\n")