コード例 #1
0
    def post(self):
        #curl --data 'businessName=alonsostestbusiness&vicinity=testVicinity&phone=%2B16052610083&geoPoint=-71.234,43.2345' http://www.levr.com/api/merchant/initialize | python -mjson.tool
        '''REMEMBER PHONE NUMBER FORMATTING STUFF'''
        api_utils.send_error(
            self,
            'Hey ethan. Ask alonso about the formatting of the phone number.')
        return

        #Grab incoming merchant data
        business_name = self.request.get('businessName')
        if business_name == '':
            api_utils.send_error(
                self, 'Required parameter not passed: businessName')
            return
        vicinity = self.request.get('vicinity')
        if vicinity == '':
            api_utils.send_error(self,
                                 'Required parameter not passed: vicinity')
            return
        phone = self.request.get('phone')
        if phone == '':
            api_utils.send_error(self, 'Required parameter not passed: phone')
            return
        geo_point = self.request.get('geoPoint')
        if geo_point == '':
            api_utils.send_error(self,
                                 'Required parameter not passed: geo_point')
            return

        #check if business entity already exists based on phone number
        business = levr.Business.gql('WHERE business_name = :1 AND phone = :2',
                                     business_name, phone).get()

        if business:
            #if a business has been created and an owner has been set, return an error
            if business.owner:
                logging.info('Owner is set!')
                api_utils.send_error(
                    self,
                    'That business has already been verified. If you need help, email [email protected]'
                )
                return
            #if a business has been created but no owner has been set, return the business
        else:
            logging.debug('Creating a new business.')
            #create a new business entity with no owner
            business = levr.Business()
            business.business_name = business_name
            business.vicinity = vicinity
            business.phone = phone
            business.geo_point = levr.geo_converter(geo_point)
            business.activation_code = str(int(time.time()))[-4:]
            #put
            business.put()

        #reply with business object
        response = {'business': api_utils.package_business(business)}
        api_utils.send_response(self, response)
コード例 #2
0
ファイル: api_merchant.py プロジェクト: holmesal/levr-2
	def post(self):
		#curl --data 'businessName=alonsostestbusiness&vicinity=testVicinity&phone=%2B16052610083&geoPoint=-71.234,43.2345' http://www.levr.com/api/merchant/initialize | python -mjson.tool
		
		'''REMEMBER PHONE NUMBER FORMATTING STUFF'''
		api_utils.send_error(self,'Hey ethan. Ask alonso about the formatting of the phone number.')
		return
		
		#Grab incoming merchant data
		business_name = self.request.get('businessName')
		if business_name == '':
			api_utils.send_error(self,'Required parameter not passed: businessName')
			return
		vicinity = self.request.get('vicinity')
		if vicinity == '':
			api_utils.send_error(self,'Required parameter not passed: vicinity')
			return
		phone = self.request.get('phone')
		if phone == '':
			api_utils.send_error(self,'Required parameter not passed: phone')
			return
		geo_point = self.request.get('geoPoint')
		if geo_point == '':
			api_utils.send_error(self,'Required parameter not passed: geo_point')
			return
		
		#check if business entity already exists based on phone number
		business = levr.Business.gql('WHERE business_name = :1 AND phone = :2',business_name,phone).get()
		
		
		if business:
			#if a business has been created and an owner has been set, return an error
			if business.owner:
				logging.info('Owner is set!')
				api_utils.send_error(self,'That business has already been verified. If you need help, email [email protected]')
				return
			#if a business has been created but no owner has been set, return the business
		else:
			logging.debug('Creating a new business.')
			#create a new business entity with no owner
			business = levr.Business()
			business.business_name = business_name
			business.vicinity = vicinity
			business.phone = phone
			business.geo_point = levr.geo_converter(geo_point)
			business.activation_code = str(int(time.time()))[-4:]
			#put
			business.put()
		
		#reply with business object
		response = {'business':api_utils.package_business(business)}
		api_utils.send_response(self,response)
コード例 #3
0
    def get(self, *args, **kwargs):
        user = kwargs.get('actor')
        levrToken = kwargs.get('levrToken')
        foursquare_id = kwargs.get('foursquareID')
        development = kwargs.get('development')
        try:
            business = levr.Business.all().filter('foursquare_id',
                                                  foursquare_id)
            deals = api_utils.fetch_all_businesses_deals(business, development)
            # package.
            packaged_deals = api_utils.package_deal_multi(deals, False)

            packaged_business = api_utils.package_business(business)

            # respond
            response = {'deals': packaged_deals, 'business': packaged_business}
            self.send_response(response)
        except Exception, e:
            levr.log_error(e)
            self.send_error()
コード例 #4
0
    def get(self, *args, **kwargs):
        user = kwargs.get('actor')
        business = kwargs.get('business')
        development = kwargs.get('development', False)

        try:
            deals = api_utils.fetch_all_businesses_deals(business, development)

            # TODO: take another look at the business packaging for the api
            # package.
            packaged_deals = api_utils.package_deal_multi(deals, False)

            packaged_business = api_utils.package_business(business)

            # respond
            response = {'deals': packaged_deals, 'business': packaged_business}
            self.send_response(response)
        except:
            levr.log_error()
            self.send_error()
コード例 #5
0
ファイル: api_business.py プロジェクト: holmesal/levr-2
	def get(self,*args,**kwargs):
		user = kwargs.get('actor')
		levrToken = kwargs.get('levrToken')
		foursquare_id = kwargs.get('foursquareID')
		development = kwargs.get('development')
		try:
			business = levr.Business.all().filter('foursquare_id',foursquare_id)
			deals = api_utils.fetch_all_businesses_deals(business, development)
			# package.
			packaged_deals = api_utils.package_deal_multi(deals, False)
			
			packaged_business = api_utils.package_business(business)
			
			# respond
			response = {
					'deals' : packaged_deals,
					'business' : packaged_business
					}
			self.send_response(response)
		except	 Exception,e:
			levr.log_error(e)
			self.send_error()
コード例 #6
0
ファイル: api_business.py プロジェクト: holmesal/levr-2
	def get(self,*args,**kwargs):
		user = kwargs.get('actor')
		business = kwargs.get('business')
		development = kwargs.get('development',False)
		
		try:
			deals = api_utils.fetch_all_businesses_deals(business, development)
			
			# TODO: take another look at the business packaging for the api
			# package.
			packaged_deals = api_utils.package_deal_multi(deals, False)
			
			packaged_business = api_utils.package_business(business)
			
			# respond
			response = {
					'deals' : packaged_deals,
					'business' : packaged_business
					}
			self.send_response(response)
		except:
			levr.log_error()
			self.send_error()
コード例 #7
0
ファイル: api_deeplink.py プロジェクト: holmesal/levr-2
	def get(self,*args,**kwargs):
		try:
			contentID = args[0]
			
			#spoof the contentID
			#contentID='85ff49d2dcb94b99973c5a2b16c5df36'
			
			#grab the associated floating content
			floating_content	=	levr.FloatingContent.gql('WHERE contentID=:1',contentID).get()
			
			action = floating_content.action
			response = {'action':action}
			
			
			
			if action == 'upload':
				business = floating_content.business
				assert business, 'Business could not be found'
				#echo back the business
				response.update({'business':api_utils.package_business(business)})
			elif action == 'deal':
				deal = floating_content.deal
				assert deal,'Deal could not be found'
				#echo bcak the deal
				packaged_deals = [api_utils.package_deal(deal)]
				response.update({'deals':packaged_deals})
			
			
			user = floating_content.user
			assert user, 'Could not find user'
			#respond, and include levr_token
			response.update({'user':api_utils.package_user(user,send_token=True)})
			
			api_utils.send_response(self,response)
		except AssertionError,e:
			levr.log_error(e)
			api_utils.send_error(self,e.message)
コード例 #8
0
    def get(self, *args, **kwargs):
        try:
            contentID = args[0]

            #spoof the contentID
            #contentID='85ff49d2dcb94b99973c5a2b16c5df36'

            #grab the associated floating content
            floating_content = levr.FloatingContent.gql(
                'WHERE contentID=:1', contentID).get()

            action = floating_content.action
            response = {'action': action}

            if action == 'upload':
                business = floating_content.business
                assert business, 'Business could not be found'
                #echo back the business
                response.update(
                    {'business': api_utils.package_business(business)})
            elif action == 'deal':
                deal = floating_content.deal
                assert deal, 'Deal could not be found'
                #echo bcak the deal
                packaged_deals = [api_utils.package_deal(deal)]
                response.update({'deals': packaged_deals})

            user = floating_content.user
            assert user, 'Could not find user'
            #respond, and include levr_token
            response.update(
                {'user': api_utils.package_user(user, send_token=True)})

            api_utils.send_response(self, response)
        except AssertionError, e:
            levr.log_error(e)
            api_utils.send_error(self, e.message)
コード例 #9
0
ファイル: api_deeplink.py プロジェクト: holmesal/levr-2
	def get(self,*args,**kwargs):
		try:
			#if we hit this handler it means that a user has both a levr account, and an account with the external service
			#we need to figure out which service (via the contentID prefix)
			#then, we need to figure out if we're dealing with two separate accounts
			#if so, we need to merge these two accounts and update references (are there any?)
			
			#grab and parse contentID to figure out what service the user has previously linked with
			
			logging.debug(kwargs)
			user = kwargs.get('actor')
			uid = user.key()
			contentID = kwargs.get('contentID')
			assert contentID,'contentID is not being passed'
#			contentID = args[0]
			service = contentID[0:3]
			#grab the floating content and the requesting user
			floating_content = levr.FloatingContent.gql('WHERE contentID=:1',contentID).get()
#			donor = floating_content.user
			
			if service=='fou':
				logging.debug('The user came from foursquare')
				if user.foursquare_connected != True:
					#add the foursquare information from the donor to the levr user
					#create an instance of the Foursquare social connection class
					task_params = {
						'uid'	:	uid,
						'contentID'	: contentID,
						'service'	: 'foursquare'
					}
					taskqueue.add(url='/tasks/mergeUsersTask',payload=json.dumps(task_params))
					
			elif service=='fac':
				logging.debug('The user came from facebook')
				if user.facbook_connected != True:
					#merge these two users
					task_params = {
						'uid'	:	uid,
						'contentID'	: contentID,
						'service'	: 'facebook'
					}
					taskqueue.add(url='/tasks/mergeUsersTask',payload=json.dumps(task_params))
					#merge stuff hereeeee
			elif service=='twi':
				logging.debug('The user came from twitter')
				if user.twitter_connected != True:
					#merge these two users
					task_params = {
						'uid'	:	uid,
						'contentID'	: contentID,
						'service'	: 'twitter'
					}
					taskqueue.add(url='/tasks/mergeUsersTask',payload=json.dumps(task_params))
					#merge stuff hereeeee
			else:
				raise Exception('contentID prefix not recognized: '+service)
				
				
			#now that that fuckery is done with, grab and return the content requested
			action = floating_content.action
			response = {'action':action}
			
			if action == 'upload':
				business = floating_content.business
				assert business, 'Business could not be found'
				#echo back the business
				response.update({'business':api_utils.package_business(business)})
			elif action == 'deal':
				deal = floating_content.deal
				assert deal,'Deal could not be found'
				#echo bcak the deal
				packaged_deals = [api_utils.package_deal(deal)]
				response.update({'deals':packaged_deals})
				
			#respond, including the token because why the hell not
			#response.update({'user':api_utils.package_user(user,send_token=True)})
			
			api_utils.send_response(self,response)
		except AssertionError,e:
			levr.log_error(e)
			api_utils.send_error(self,e.message)
コード例 #10
0
    def get(self, *args, **kwargs):
        '''
		@return: <business>
		'''
        logging.info(kwargs)
        business_name = kwargs.get('businessName')
        vicinity = kwargs.get('vicinity')
        geo_point = kwargs.get('geoPoint')
        radius = kwargs.get('radius')  # TODO: implement radius to search
        try:
            # create a set of geo hashes to search based on the radius
            search = api_utils.Search(True)
            precision = 5
            ghash_list, bounding_box = search.create_ghash_list(
                geo_point, precision)

            logging.info(ghash_list)
            # get deal keys
            for ghash in ghash_list:
                business_keys = levr.Business.all(keys_only=True).filter(
                    'geo_hash_prefixes', ghash).fetch(None)

            # fetch all businesses
            businesses = db.get(business_keys)

            # filter the businesses by the tags
            search_tags = set([])
            if business_name:
                search_tags.update(levr.create_tokens(business_name))
            if vicinity:
                search_tags.update(levr.create_tokens(vicinity))
            logging.info(search_tags)
            # map the quality of the match by the number of tags that match the business
            for business in businesses:
                business_tags = business.tags
                business.rank = 0
                for tag in business_tags:
                    if tag in search_tags:
                        business.rank += 1
            # assure that a business was found
            assert businesses, 'Could not find a business'
            # sort the businesses by their quality
            ranks = [b.rank for b in businesses]
            toop = zip(ranks, businesses)
            toop.sort()
            ranks, businesses = zip(*toop)

            # get the highest ranking business
            business = businesses[0]

            # get all deals from that business
            deals = levr.Deal.all(keys_only=True).ancestor(
                business.key()).filter('deal_status',
                                       levr.DEAL_STATUS_ACTIVE).fetch(None)

            packaged_deals = api_utils.package_deal_multi(deals)
            packaged_business = api_utils.package_business(business)
            response = {'business': packaged_business, 'deals': packaged_deals}
            self.send_response(response)
        except AssertionError, e:
            self.send_error(e)
コード例 #11
0
ファイル: api_merchant.py プロジェクト: holmesal/levr-2
	def post(self,*args,**kwargs): #@UnusedVariable
		'''
		Checks for existing account with that business
		If the account exists, return true
		
		@attention: Only handles the case where a single account is tied to no more than one business
		
		@keyword email: required
		@keyword password: required
		@keyword business_name: required
		@keyword vicinity: required
		@keyword geo_point: required
		@keyword types: require
		@keyword development: optional
		
		@return: packaged_user with levrToken, packaged_business
		'''
		# for invalid credential responses
		user_doesnt_own_business_message = 'User does not own that business'
		# for packaging
		private = True
		followers = False
		
		# input values
		email = kwargs.get('email')
		password = kwargs.get('pw')
		business_name = kwargs.get('businessName')
		vicinity = kwargs.get('vicinity')
		geo_point = kwargs.get('geoPoint')
		types = kwargs.get('types')
		development = kwargs.get('development',False) # TODO: switch this to False by default when changing to live
		phone_number = kwargs.get('phoneNumber','')
		try:
			# Convert input data
			password = enc.encrypt_password(password)
			types = types.split(',')
			
			logging.debug('{}\n{}\n{}\n{}'.format(repr(business_name),repr(vicinity),geo_point,repr(types)))
			
			# check for existing entities
			user = levr.Customer.all().filter('email',email).get()
			requested_business = levr.Business.all().filter('business_name',business_name).filter('vicinity',vicinity).get()
			
			if user:
				logging.info('User exists')
				# check password
				assert user.pw == password, 'Password does not match username'
				
				# user should have a business
				try:
					business = user.businesses.get()
					# if the user has a business, it should be the business that was requested
					assert business, 'User does not own any businesses yet'
				except:
					logging.debug('user does not have a business yet - create one')
					# if the user does not have a business yet, add this one.
					business = levr.create_new_business(business_name,vicinity,geo_point,types,phone_number,
													owner=user
													)
#					assert False, user_doesnt_own_business_message
				else:
					logging.debug('User owns a business')
#					logging.debug(levr.log_model_props(business.owner))
#					logging.debug(levr.log_model_props(requested_business.owner))
#					if requested_business:
#						assert business.key() == requested_business.key(), user_doesnt_own_business_message
			else:
				logging.debug('User does not exist. Create a new one!!')
				# Create an account for the user with that business
				user = levr.create_new_user(
										tester=development,
										pw=password,
										email=email,
										display_name=business_name,
										)
				logging.debug(business_name)
				logging.debug(levr.log_model_props(user))
				if not requested_business:
					logging.debug('requested business was not found')
					business = levr.create_new_business(business_name,vicinity,geo_point,types,phone_number,
													owner=user
													)
				else:
					logging.debug('requested business was found')
					business = requested_business
					# 
					business.owner = user
					business.put()
			
			logging.debug('business: '+repr(business))
			#===================================================================
			# # Send message to the founders that someone has signed up for the app
			#===================================================================
			if not development:
				try:
					from google.appengine.api import mail
					message = mail.AdminEmailMessage(
													sender = '*****@*****.**',
													subject = 'New Merchant',
													)
					message.body = levr.log_model_props(user,['email','display_name',])
					message.body += levr.log_model_props(business,['business_name','vicinity'])
					message.check_initialized()
					message.send()
					
				except:
					levr.log_error()
			
			#===================================================================
			# # package and send
			#===================================================================
			packaged_user = api_utils.package_user(user, private, followers,send_token=True)
			packaged_business = api_utils.package_business(business)
			response = {
					'user' : packaged_user,
					'business' : packaged_business
					}
			self.send_response(response)
			# TODO: Merchant connect - handle all cases - new and existing accounts
		except AssertionError,e:
			levr.log_error()
			self.send_error(e)
コード例 #12
0
ファイル: api_business.py プロジェクト: holmesal/levr-2
	def get(self,*args,**kwargs):
		'''
		@return: <business>
		'''
		logging.info(kwargs)
		business_name = kwargs.get('businessName')
		vicinity = kwargs.get('vicinity')
		geo_point = kwargs.get('geoPoint')
		radius = kwargs.get('radius') # TODO: implement radius to search
		try:
			# create a set of geo hashes to search based on the radius
			search = api_utils.Search(True)
			precision = 5
			ghash_list,bounding_box = search.create_ghash_list(geo_point, precision)
			
			logging.info(ghash_list)
			# get deal keys
			for ghash in ghash_list:
				business_keys = levr.Business.all(keys_only=True
											).filter('geo_hash_prefixes',ghash
											).fetch(None)
			
			# fetch all businesses
			businesses = db.get(business_keys)
			
			# filter the businesses by the tags
			search_tags = set([])
			if business_name:
				search_tags.update(levr.create_tokens(business_name))
			if vicinity:
				search_tags.update(levr.create_tokens(vicinity))
			logging.info(search_tags)
			# map the quality of the match by the number of tags that match the business
			for business in businesses:
				business_tags = business.tags
				business.rank = 0
				for tag in business_tags:
					if tag in search_tags:
						business.rank += 1
			# assure that a business was found
			assert businesses, 'Could not find a business'
			# sort the businesses by their quality
			ranks = [b.rank for b in businesses]
			toop = zip(ranks,businesses)
			toop.sort()
			ranks,businesses = zip(*toop)
			
			# get the highest ranking business
			business = businesses[0]
			
			# get all deals from that business
			deals = levr.Deal.all(keys_only=True
								).ancestor(business.key()
								).filter('deal_status',levr.DEAL_STATUS_ACTIVE
								).fetch(None)
			
			packaged_deals = api_utils.package_deal_multi(deals)
			packaged_business = api_utils.package_business(business)
			response = {
					'business' : packaged_business,
					'deals' : packaged_deals
					}
			self.send_response(response)
		except AssertionError,e:
			self.send_error(e)
コード例 #13
0
    def get(self, *args, **kwargs):
        try:
            #if we hit this handler it means that a user has both a levr account, and an account with the external service
            #we need to figure out which service (via the contentID prefix)
            #then, we need to figure out if we're dealing with two separate accounts
            #if so, we need to merge these two accounts and update references (are there any?)

            #grab and parse contentID to figure out what service the user has previously linked with

            logging.debug(kwargs)
            user = kwargs.get('actor')
            uid = user.key()
            contentID = kwargs.get('contentID')
            assert contentID, 'contentID is not being passed'
            #			contentID = args[0]
            service = contentID[0:3]
            #grab the floating content and the requesting user
            floating_content = levr.FloatingContent.gql(
                'WHERE contentID=:1', contentID).get()
            #			donor = floating_content.user

            if service == 'fou':
                logging.debug('The user came from foursquare')
                if user.foursquare_connected != True:
                    #add the foursquare information from the donor to the levr user
                    #create an instance of the Foursquare social connection class
                    task_params = {
                        'uid': uid,
                        'contentID': contentID,
                        'service': 'foursquare'
                    }
                    taskqueue.add(url='/tasks/mergeUsersTask',
                                  payload=json.dumps(task_params))

            elif service == 'fac':
                logging.debug('The user came from facebook')
                if user.facbook_connected != True:
                    #merge these two users
                    task_params = {
                        'uid': uid,
                        'contentID': contentID,
                        'service': 'facebook'
                    }
                    taskqueue.add(url='/tasks/mergeUsersTask',
                                  payload=json.dumps(task_params))
                    #merge stuff hereeeee
            elif service == 'twi':
                logging.debug('The user came from twitter')
                if user.twitter_connected != True:
                    #merge these two users
                    task_params = {
                        'uid': uid,
                        'contentID': contentID,
                        'service': 'twitter'
                    }
                    taskqueue.add(url='/tasks/mergeUsersTask',
                                  payload=json.dumps(task_params))
                    #merge stuff hereeeee
            else:
                raise Exception('contentID prefix not recognized: ' + service)

            #now that that fuckery is done with, grab and return the content requested
            action = floating_content.action
            response = {'action': action}

            if action == 'upload':
                business = floating_content.business
                assert business, 'Business could not be found'
                #echo back the business
                response.update(
                    {'business': api_utils.package_business(business)})
            elif action == 'deal':
                deal = floating_content.deal
                assert deal, 'Deal could not be found'
                #echo bcak the deal
                packaged_deals = [api_utils.package_deal(deal)]
                response.update({'deals': packaged_deals})

            #respond, including the token because why the hell not
            #response.update({'user':api_utils.package_user(user,send_token=True)})

            api_utils.send_response(self, response)
        except AssertionError, e:
            levr.log_error(e)
            api_utils.send_error(self, e.message)
コード例 #14
0
    def post(self, *args, **kwargs):  #@UnusedVariable
        '''
		Checks for existing account with that business
		If the account exists, return true
		
		@attention: Only handles the case where a single account is tied to no more than one business
		
		@keyword email: required
		@keyword password: required
		@keyword business_name: required
		@keyword vicinity: required
		@keyword geo_point: required
		@keyword types: require
		@keyword development: optional
		
		@return: packaged_user with levrToken, packaged_business
		'''
        # for invalid credential responses
        user_doesnt_own_business_message = 'User does not own that business'
        # for packaging
        private = True
        followers = False

        # input values
        email = kwargs.get('email')
        password = kwargs.get('pw')
        business_name = kwargs.get('businessName')
        vicinity = kwargs.get('vicinity')
        geo_point = kwargs.get('geoPoint')
        types = kwargs.get('types')
        development = kwargs.get(
            'development', False
        )  # TODO: switch this to False by default when changing to live
        phone_number = kwargs.get('phoneNumber', '')
        try:
            # Convert input data
            password = enc.encrypt_password(password)
            types = types.split(',')

            logging.debug('{}\n{}\n{}\n{}'.format(repr(business_name),
                                                  repr(vicinity), geo_point,
                                                  repr(types)))

            # check for existing entities
            user = levr.Customer.all().filter('email', email).get()
            requested_business = levr.Business.all().filter(
                'business_name', business_name).filter('vicinity',
                                                       vicinity).get()

            if user:
                logging.info('User exists')
                # check password
                assert user.pw == password, 'Password does not match username'

                # user should have a business
                try:
                    business = user.businesses.get()
                    # if the user has a business, it should be the business that was requested
                    assert business, 'User does not own any businesses yet'
                except:
                    logging.debug(
                        'user does not have a business yet - create one')
                    # if the user does not have a business yet, add this one.
                    business = levr.create_new_business(business_name,
                                                        vicinity,
                                                        geo_point,
                                                        types,
                                                        phone_number,
                                                        owner=user)
#					assert False, user_doesnt_own_business_message
                else:
                    logging.debug('User owns a business')


#					logging.debug(levr.log_model_props(business.owner))
#					logging.debug(levr.log_model_props(requested_business.owner))
#					if requested_business:
#						assert business.key() == requested_business.key(), user_doesnt_own_business_message
            else:
                logging.debug('User does not exist. Create a new one!!')
                # Create an account for the user with that business
                user = levr.create_new_user(
                    tester=development,
                    pw=password,
                    email=email,
                    display_name=business_name,
                )
                logging.debug(business_name)
                logging.debug(levr.log_model_props(user))
                if not requested_business:
                    logging.debug('requested business was not found')
                    business = levr.create_new_business(business_name,
                                                        vicinity,
                                                        geo_point,
                                                        types,
                                                        phone_number,
                                                        owner=user)
                else:
                    logging.debug('requested business was found')
                    business = requested_business
                    #
                    business.owner = user
                    business.put()

            logging.debug('business: ' + repr(business))
            #===================================================================
            # # Send message to the founders that someone has signed up for the app
            #===================================================================
            if not development:
                try:
                    from google.appengine.api import mail
                    message = mail.AdminEmailMessage(
                        sender='*****@*****.**',
                        subject='New Merchant',
                    )
                    message.body = levr.log_model_props(
                        user, [
                            'email',
                            'display_name',
                        ])
                    message.body += levr.log_model_props(
                        business, ['business_name', 'vicinity'])
                    message.check_initialized()
                    message.send()

                except:
                    levr.log_error()

            #===================================================================
            # # package and send
            #===================================================================
            packaged_user = api_utils.package_user(user,
                                                   private,
                                                   followers,
                                                   send_token=True)
            packaged_business = api_utils.package_business(business)
            response = {'user': packaged_user, 'business': packaged_business}
            self.send_response(response)
            # TODO: Merchant connect - handle all cases - new and existing accounts
        except AssertionError, e:
            levr.log_error()
            self.send_error(e)