Esempio n. 1
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()
Esempio n. 2
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()
Esempio n. 3
0
    def get(self, *args, **kwargs):  #@UnusedVariable
        '''
		@keyword actor:
		
		@return: array of deal objects
		'''
        user = kwargs.get('actor')
        try:
            deals = api_utils.fetch_all_users_deals(user)

            # package deals
            private = True
            packaged_deals = api_utils.package_deal_multi(deals, private)

            # return
            response = {'deals': packaged_deals}
            self.send_response(response, user)

        except Exception, e:
            levr.log_error(e)
            self.send_error()
Esempio n. 4
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()
Esempio n. 5
0
	def get(self,*args,**kwargs): #@UnusedVariable
		'''
		@keyword actor:
		
		@return: array of deal objects
		'''
		user = kwargs.get('actor')
		try:
			deals = api_utils.fetch_all_users_deals(user)
			
			# package deals
			private = True
			packaged_deals = api_utils.package_deal_multi(deals, private)
			
			# return
			response = {
					'deals' : packaged_deals
					}
			self.send_response(response, user)
			
		except Exception,e:
			levr.log_error(e)
			self.send_error()
Esempio n. 6
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()
Esempio n. 7
0
    def get(self):
        #launch the jinja environment
        jinja_environment = jinja2.Environment(
            loader=jinja2.FileSystemLoader(os.path.dirname(__file__)))

        #check user-agent to see if user is mobile or not
        #get the user-agent
        # 		uastring = str(self.request.headers['user-agent'])

        # 		logging.info(uastring)

        #same template for mobile and desktop (for now)
        # if 'Mobile' in uastring:
        # 			if 'iPad' in uastring:
        # 				logging.info('THIS IS AN iPad')
        # 				#serve desktop landing page
        # 				template = jinja_environment.get_template('templates/landing_v3.html')
        # 			else:
        # 				logging.info('THIS IS A MOBILE DEVICE')
        # 				#serve mobile landing page
        # 				template = jinja_environment.get_template('templates/landing_v3.html')
        # 		else:
        # 			logging.info('THIS IS A DESKTOP DEVICE')
        # 			#serve desktop landing page
        # 			template = jinja_environment.get_template('templates/landing_v3.html')

        #choices = ['Version A','Version B']
        #version = random.choice(choices)

        # 		version = 'Version B'
        #
        # 		logging.info('Serving: '+version)
        # 		template_values = {
        # 			"version"	:	version
        # 		}
        #
        # 		if version == 'Version A':
        # 			template_values.update({'css':'landing_v3_version_a'})
        # 		elif version == 'Version B':
        # 			template_values.update({'css':'landing_v3_version_b'})
        #
        # 		template = jinja_environment.get_template('templates/landing_v3_final.html')
        # 		self.response.out.write(template.render(template_values))

        uastring = str(self.request.headers['user-agent'])

        logging.info(uastring)

        if 'iphone' in uastring.lower():
            version = 'iPhone'
            logging.debug('Serving mobile version - iPhone')
        elif 'android' in uastring.lower():
            version = 'android'
            logging.debug('Serving mobile version - android')
        else:
            version = 'desktop'
            logging.debug('Serving desktop version')

        logging.info(self.request.get('city'))

        city = self.request.get('city')
        logging.info(city)

        if city == 'sanfrancisco':
            #huge san francisco geohashes (+ palo alto)
            geo_hash_set = [
                '9q8z', '9q8y', '9q8v', '9q8p', '9q8n', '9q8j', '9q9h'
            ]
        else:
            #huge boston geohashes
            geo_hash_set = [
                'drt3', 'drmr', 'drt8', 'drt0', 'drt1', 'drt9', 'drmx', 'drmp',
                'drt2'
            ]

        logging.debug('\n\n\n \t\t\t START QUERYING \n\n\n')
        query_start = datetime.now()
        deal_keys = api_utils.get_deal_keys(geo_hash_set)
        query_end = datetime.now()

        total_query_time = query_end - query_start

        logging.debug('\n\n\n \t\t\t END QUERYING \n\n\n ')

        logging.info('Query time: ' + str(total_query_time))

        deals = db.get(deal_keys)

        sorted_deals = []
        #remove the non-active and foursquare deals
        for deal in deals:
            logging.debug(deal.deal_status)
            if deal.deal_status in ['active']:
                logging.debug(deal.origin)
                if deal.origin in ['levr', 'merchant']:
                    sorted_deals.append(deal)
                else:
                    logging.info('deal not added because origin was: ' +
                                 deal.origin)
            else:
                logging.info('deal not added because status was:' +
                             deal.deal_status)

        packaged_deals = api_utils.package_deal_multi(sorted_deals)

        # 		logging.info(packaged_deals)

        #go through and swap lat and lon
        for deal in packaged_deals:
            logging.info(deals)
            #separate lat and lon
            deal['lat'] = deal['business']['geoPoint'].split(',')[0]
            deal['lon'] = deal['business']['geoPoint'].split(',')[1]
            #fix image url
            deal['imgURL'] = deal['largeImg'].split(
                '?')[0] + '?size=webMapView'
            deal['description'] = deal['description'].replace('\n', ' ')

        template_values = {
            'deals': packaged_deals,
            'version': version,
            'city': city
        }

        #launch the jinja environment
        jinja_environment = jinja2.Environment(
            loader=jinja2.FileSystemLoader(os.path.dirname(__file__)))
        template = jinja_environment.get_template('templates/landing_v4.html')
        self.response.out.write(template.render(template_values))
Esempio n. 8
0
    def get(self):

        geo_hash_set = [
            'drt3', 'drmr', 'drt8', 'drt0', 'drt1', 'drt9', 'drmx', 'drmp',
            'drt2'
        ]

        active_dict = api_utils.get_deal_keys_from_db(geo_hash_set, 'active',
                                                      None)
        active_keys = []
        for active in active_dict:
            active_keys.extend(active_dict[active])

        expired_dict = api_utils.get_deal_keys_from_db(geo_hash_set, 'expired',
                                                       None)
        expired_keys = []
        for expired in expired_dict:
            expired_keys.extend(expired_dict[expired])

        rejected_dict = api_utils.get_deal_keys_from_db(
            geo_hash_set, 'rejected', None)
        rejected_keys = []
        for rejected in rejected_dict:
            rejected_keys.extend(rejected_dict[rejected])

        deals = db.get(active_keys + expired_keys + rejected_keys)

        packaged_deals = api_utils.package_deal_multi(deals)

        # 			logging.info(packaged_deals)

        active_deals = []
        expired_deals = []
        rejected_deals = []

        for deal in packaged_deals:

            deal['lat'] = deal['business']['geoPoint'].split(',')[0]
            deal['lon'] = deal['business']['geoPoint'].split(',')[1]
            #fix image url
            deal['imgURL'] = deal['largeImg'].split(
                '?')[0] + '?size=webMapView'
            #links

            # 				logging.info(deal['origin'])
            if deal['origin'] != 'foursquare':
                if deal['origin'] == 'levr':
                    deal['pin_style'] = 'star'
                elif deal['origin'] == 'merchant':
                    deal['pin_style'] = 'dot'
                else:
                    deal['pin_style'] = 'question-mark'

# 				logging.info(deal['status'])
                if deal['status'] == 'active':
                    deal['pin_color'] = '60b03c'
                    active_deals.append(deal)
                elif deal['status'] == 'expired':
                    deal['pin_color'] = 'dfb72a'
                    expired_deals.append(deal)
                elif deal['status'] == 'rejected':
                    deal['pin_color'] = 'df2a2a'
                    rejected_deals.append(deal)

        template_values = {
            "active_deals": active_deals,
            "expired_deals": expired_deals,
            "rejected_deals": rejected_deals
        }

        # 			logging.info(template_values)

        #launch the jinja environment
        jinja_environment = jinja2.Environment(
            loader=jinja2.FileSystemLoader(os.path.dirname(__file__)))
        template = jinja_environment.get_template('templates/dashboard.html')
        self.response.out.write(template.render(template_values))
Esempio n. 9
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)
Esempio n. 10
0
	def post(self,*args,**kwargs): #@UnusedVariable
		'''
		@keyword actor: required
		@keyword deal: required
		@keyword description: optional
		@keyword dealText: optional
		
		@var new_img_key: optional - the blob key of the uploaded image
		
		@return: the new deal object
		@rtype: dict
		'''
		user = kwargs.get('actor')
		deal = kwargs.get('deal')
		description = kwargs.get('description',None)
		deal_text = kwargs.get('dealText',None)
		try:
			# assure that the user is the owner of the deal
			assert deal.parent_key() == user.key(), 'User does not own that deal'
			
			#===================================================================
			# Check for image upload
			#===================================================================
			if self.get_uploads():
				new_img_key	= self.get_uploads()[0].key()
				# grab old key so we can delete it
				old_img_key = deal.img
				# replace with new key
				deal.img = new_img_key
				# delete that old key
				old_img_key.delete()
				
				try:
					# Synchronously rotate the image
					api_utils.rotate_image(new_img_key)
				except:
					levr.log_error('An image could not be rotated. \
						It was sent to the task que: '+str(new_img_key))
					# Send the image to the img rotation task que
					task_params = {
									'blob_key'	:	str(new_img_key)
									}
					logging.info('Sending this to the img rotation task: '+str(task_params))
					
					taskqueue.add(url=IMAGE_ROTATION_TASK_URL,payload=json.dumps(task_params))
				
			else:
				assert description or deal_text, 'Thanks for sending me something to update.'
			#===================================================================
			# Update new deal informations
			#===================================================================
			if description:
				deal.description = description
			if deal_text:
				deal.deal_text = deal_text
			
			# TODO: add new tags to the deal for the new information that was added
			
			
			
			deal.put()
			
			
			private = True
			deals = api_utils.fetch_all_users_deals(user)
			packaged_deals = api_utils.package_deal_multi(deals, private)
			
			
			response = {
					'deals'	: packaged_deals
					}
			api_utils.send_response(self,response, user)
			
		except AssertionError,e:
			api_utils.send_error(self,e.message)
Esempio n. 11
0
	def post(self,*args,**kwargs): #@UnusedVariable
		'''
		@keyword actor: required
		@keyword business: required
		@keyword description: required
		@keyword deal_text: required
		@keyword development: required
		
		@requires: an image is uploaded - need the blob_key
		
		@return: the newly created deal object
		@rtype: dict
		'''
		user = kwargs.get('actor')
		business = kwargs.get('business')
		description = kwargs.get('description')
		deal_text = kwargs.get('dealText')
		development = kwargs.get('development')
		img_key = ''
		try:
			
			#===================================================================
			# Assure that an image was uploaded
			#===================================================================
			if self.get_uploads():
				upload	= self.get_uploads()[0]
				blob_key= upload.key()
				img_key = blob_key
				upload_flag = True
				
				
				
			else:
				upload_flag = False
				raise KeyError('Image was not uploaded')
			
			#===================================================================
			# Assemble the deal parameters! And create the deal!!
			#===================================================================
			params = {
					'user'				: user,
					'uid'				: user.key(),
					'business'			: business,
					'deal_description'	: description,
					'deal_line1'		: deal_text,
					'development'		: development,
					'img_key'			: img_key
					}
			# TODO: add pin_color = 'green' to the deal
			# TODO: add origin = 'merchant'
			deal_entity = levr.dealCreate(params, 'phone_merchant', upload_flag)
			
			# if an image was uploaded, rotate it.
			if upload_flag == True:
				try:
					# Synchronously rotate the image
					api_utils.rotate_image(blob_key,deal_entity)
				except:
					levr.log_error('An image could not be rotated. It was sent to the task que: '+str(blob_key))
					# Send the image to the img rotation task que
					task_params = {
									'blob_key'	:	str(blob_key)
									}
					logging.info('Sending this to the img rotation task: '+str(task_params))
					
					taskqueue.add(url=IMAGE_ROTATION_TASK_URL,payload=json.dumps(task_params))
			
			#===================================================================
			# Aw hell.. why not give them some karma too.
			#===================================================================
			user.karma += 5
			# no need to level_check on them though...
			user.put()
			
			#===================================================================
			# Create some nifty notifications
			#===================================================================
			try:
				levr.create_notification('followedUpload',user.followers,user.key(),deal_entity)
			except:
				levr.log_error()
			
			#===================================================================
			# Respond with all of the users deals
			#===================================================================
			private = True
			deals = api_utils.fetch_all_users_deals(user)
			packaged_deals = api_utils.package_deal_multi(deals, private)
			
			response = {
					'deals'	: packaged_deals
					}
			
			api_utils.send_response(self,response, user)
			
		except Exception,e:
			levr.log_error(e)
			api_utils.send_error(self,'Server Error')
Esempio n. 12
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)
Esempio n. 13
0
    def post(self, *args, **kwargs):  #@UnusedVariable
        '''
		@keyword actor: required
		@keyword deal: required
		@keyword description: optional
		@keyword dealText: optional
		
		@var new_img_key: optional - the blob key of the uploaded image
		
		@return: the new deal object
		@rtype: dict
		'''
        user = kwargs.get('actor')
        deal = kwargs.get('deal')
        description = kwargs.get('description', None)
        deal_text = kwargs.get('dealText', None)
        try:
            # assure that the user is the owner of the deal
            assert deal.parent_key() == user.key(
            ), 'User does not own that deal'

            #===================================================================
            # Check for image upload
            #===================================================================
            if self.get_uploads():
                new_img_key = self.get_uploads()[0].key()
                # grab old key so we can delete it
                old_img_key = deal.img
                # replace with new key
                deal.img = new_img_key
                # delete that old key
                old_img_key.delete()

                try:
                    # Synchronously rotate the image
                    api_utils.rotate_image(new_img_key)
                except:
                    levr.log_error('An image could not be rotated. \
						It was sent to the task que: ' + str(new_img_key))
                    # Send the image to the img rotation task que
                    task_params = {'blob_key': str(new_img_key)}
                    logging.info('Sending this to the img rotation task: ' +
                                 str(task_params))

                    taskqueue.add(url=IMAGE_ROTATION_TASK_URL,
                                  payload=json.dumps(task_params))

            else:
                assert description or deal_text, 'Thanks for sending me something to update.'
            #===================================================================
            # Update new deal informations
            #===================================================================
            if description:
                deal.description = description
            if deal_text:
                deal.deal_text = deal_text

            # TODO: add new tags to the deal for the new information that was added

            deal.put()

            private = True
            deals = api_utils.fetch_all_users_deals(user)
            packaged_deals = api_utils.package_deal_multi(deals, private)

            response = {'deals': packaged_deals}
            api_utils.send_response(self, response, user)

        except AssertionError, e:
            api_utils.send_error(self, e.message)
Esempio n. 14
0
    def post(self, *args, **kwargs):  #@UnusedVariable
        '''
		@keyword actor: required
		@keyword business: required
		@keyword description: required
		@keyword deal_text: required
		@keyword development: required
		
		@requires: an image is uploaded - need the blob_key
		
		@return: the newly created deal object
		@rtype: dict
		'''
        user = kwargs.get('actor')
        business = kwargs.get('business')
        description = kwargs.get('description')
        deal_text = kwargs.get('dealText')
        development = kwargs.get('development')
        img_key = ''
        try:

            #===================================================================
            # Assure that an image was uploaded
            #===================================================================
            if self.get_uploads():
                upload = self.get_uploads()[0]
                blob_key = upload.key()
                img_key = blob_key
                upload_flag = True

            else:
                upload_flag = False
                raise KeyError('Image was not uploaded')

            #===================================================================
            # Assemble the deal parameters! And create the deal!!
            #===================================================================
            params = {
                'user': user,
                'uid': user.key(),
                'business': business,
                'deal_description': description,
                'deal_line1': deal_text,
                'development': development,
                'img_key': img_key
            }
            # TODO: add pin_color = 'green' to the deal
            # TODO: add origin = 'merchant'
            deal_entity = levr.dealCreate(params, 'phone_merchant',
                                          upload_flag)

            # if an image was uploaded, rotate it.
            if upload_flag == True:
                try:
                    # Synchronously rotate the image
                    api_utils.rotate_image(blob_key, deal_entity)
                except:
                    levr.log_error(
                        'An image could not be rotated. It was sent to the task que: '
                        + str(blob_key))
                    # Send the image to the img rotation task que
                    task_params = {'blob_key': str(blob_key)}
                    logging.info('Sending this to the img rotation task: ' +
                                 str(task_params))

                    taskqueue.add(url=IMAGE_ROTATION_TASK_URL,
                                  payload=json.dumps(task_params))

            #===================================================================
            # Aw hell.. why not give them some karma too.
            #===================================================================
            user.karma += 5
            # no need to level_check on them though...
            user.put()

            #===================================================================
            # Create some nifty notifications
            #===================================================================
            try:
                levr.create_notification('followedUpload', user.followers,
                                         user.key(), deal_entity)
            except:
                levr.log_error()

            #===================================================================
            # Respond with all of the users deals
            #===================================================================
            private = True
            deals = api_utils.fetch_all_users_deals(user)
            packaged_deals = api_utils.package_deal_multi(deals, private)

            response = {'deals': packaged_deals}

            api_utils.send_response(self, response, user)

        except Exception, e:
            levr.log_error(e)
            api_utils.send_error(self, 'Server Error')
Esempio n. 15
0
		def get(self):
			
			geo_hash_set = ['drt3','drmr','drt8','drt0','drt1','drt9','drmx','drmp','drt2']
			
			active_dict = api_utils.get_deal_keys_from_db(geo_hash_set,'active',None)
			active_keys = []
			for active in active_dict:
				active_keys.extend(active_dict[active])
				
			expired_dict = api_utils.get_deal_keys_from_db(geo_hash_set,'expired',None)
			expired_keys = []
			for expired in expired_dict:
				expired_keys.extend(expired_dict[expired])
				
			rejected_dict = api_utils.get_deal_keys_from_db(geo_hash_set,'rejected',None)
			rejected_keys = []
			for rejected in rejected_dict:
				rejected_keys.extend(rejected_dict[rejected])
			
			deals = db.get(active_keys+expired_keys+rejected_keys)
			
			packaged_deals = api_utils.package_deal_multi(deals)
			
# 			logging.info(packaged_deals)
			

			
			active_deals = []
			expired_deals = []
			rejected_deals = []
			
			
			for deal in packaged_deals:
				
				deal['lat'] = deal['business']['geoPoint'].split(',')[0]
				deal['lon'] = deal['business']['geoPoint'].split(',')[1]
				#fix image url
				deal['imgURL'] = deal['largeImg'].split('?')[0]+'?size=webMapView'
				#links
				
				
# 				logging.info(deal['origin'])
				if deal['origin'] != 'foursquare':
					if deal['origin'] == 'levr':
						deal['pin_style'] = 'star'
					elif deal['origin'] == 'merchant':
						deal['pin_style'] = 'dot'
					else:
						deal['pin_style'] = 'question-mark'
					
	# 				logging.info(deal['status'])
					if deal['status'] == 'active':
						deal['pin_color'] = '60b03c'
						active_deals.append(deal)
					elif deal['status'] == 'expired':
						deal['pin_color'] = 'dfb72a'
						expired_deals.append(deal)
					elif deal['status'] == 'rejected':
						deal['pin_color'] = 'df2a2a'
						rejected_deals.append(deal)
				
				
				
				
			template_values = {
				"active_deals"		:	active_deals,
				"expired_deals"		:	expired_deals,
				"rejected_deals"	:	rejected_deals
			}
			
# 			logging.info(template_values)
			
			#launch the jinja environment
			jinja_environment = jinja2.Environment(loader=jinja2.FileSystemLoader(os.path.dirname(__file__)))
			template = jinja_environment.get_template('templates/dashboard.html')
			self.response.out.write(template.render(template_values))