Esempio n. 1
0
	def post(self):
		postType = cgi.escape(self.request.get('createOrUpdate'))

		business_id = cgi.escape(self.request.get('business_id'))
		if postType == 'hide':
			self.__HideBusiness(business_id)
		else:
			business = Business()

			business.name = cgi.escape(self.request.get('name'))
			business.url = cgi.escape(self.request.get('url'))
			business.province = cgi.escape(self.request.get('province'))
			business.city = cgi.escape(self.request.get('city'))
			business.street = cgi.escape(self.request.get('street'))
			business.phonenumber = cgi.escape(self.request.get('phone'))
			hide = cgi.escape(self.request.get('hide'))
			if hide == 'True':
				business.hidden = True
			else:
				business.hidden = False
		
			if postType == 'update':
				business.business_id = business_id
				BusinessService().updateBusiness(business)
			else:
				BusinessService().saveBusiness(business);
				
		self.redirect('/businessservice/')
Esempio n. 2
0
	def buildBusinessDetailsFromJson(self, json):	
		if 'id' in json:	
			business = Business()
			business.business_id = self.formatYellowPagesId(json['id'])
			business.name = json['name']
			if 'address' in json:
				if json['address']:
					address = json['address']
					business.city = address['city']
					business.province = address['prov']
					business.country = 'Canada'
					business.street = address['street']
			if 'geoCode' in json:
				if json['geoCode']:
					geolocation = json['geoCode']
					lat = geolocation['latitude']
					lon = geolocation['longitude']
					business.geolocation = GeoLocation(lat, lon)
			if 'phones' in json:
				if json['phones']:
					phones = json['phones']
					for phone in phones:
						if 'type' in phone:
							phoneType = phone['type']
							if phoneType == 'primary':
								business.phonenumber = phone['dispNum']
			if 'merchantUrl' in json:
				if json['merchantUrl']:
					url = json['merchantUrl']
					business.url = url
			return business
		else:
			return None
Esempio n. 3
0
	def convertDbBusinessToBusiness(self, dbBusiness):
		business = None
		if dbBusiness:
			business = Business()
			business.name = dbBusiness.name
			business.url = dbBusiness.url
			business.country = dbBusiness.country
			business.province = dbBusiness.province
			business.city = dbBusiness.city
			business.street = dbBusiness.street
			business.postalcode = dbBusiness.postalcode
			business.phonenumber = dbBusiness.phonenumber
			if dbBusiness.hidden != None:
				business.hidden = dbBusiness.hidden
			business.geolocation = self.convertGeoPTToGeoLocation(dbBusiness.location)
			business.business_id = str(dbBusiness.key().id())
		return business
Esempio n. 4
0
	def buildBusinessFromJson(self, json):	
		businesses = []	
		if 'listings' in json:
			listings = json['listings']		
			for listing in listings:
				business = Business()
				business.business_id = self.formatYellowPagesId(listing['id'])
				business.name = listing['name']
				if 'address' in listing:
					if listing['address']:
						address = listing['address']
						business.city = address['city']
						business.province = address['prov']
						business.country = 'Canada'
						business.street = address['street']
				if 'geoCode' in listing:
					if listing['geoCode']:
						geolocation = listing['geoCode']
						lat = geolocation['latitude']
						lon = geolocation['longitude']
						business.geolocation = GeoLocation(lat, lon)
				businesses.append(business)
		return businesses