Beispiel #1
0
 def post(self):
     cookies = h.get_default_cookies(self)
     current_user = h.get_current_user(cookies)
     
   	if current_user != None and '_pvk' in cookies and cookies['_pvk'] != None and cookies['_pvk'] != '':
         unlinked_result_views = ResultView.gql("WHERE session_id = :1 AND user = NULL", cookies['_pvk']).fetch(5)
         for result_view in unlinked_result_views:
             result_view.user = current_user
             if current_user.fb_user_id != None:
                 result_view.fb_user_id = current_user.fb_user_id
             
             # Create a "backdated" version for this query, because the user probably made the query while 
             # logged out, and it's worthwile knowing that that happened
             if result_view.query_string != None and result_view.query_string != '':
                 query = Query(query_string = result_view.query_string, referrer = self.request.referer, url = "__ARTIFICIALLY_CREATED_FOR_USER__")
                 
                 query.user = current_user
                 if current_user.fb_user_id != None:
                     query.fb_user_id = current_user.fb_user_id
                 if '_pvk' in cookies and cookies['_pvk'] != None and cookies['_pvk'] != '':
                     query.session_id = cookies['_pvk']
                 
                 query.put()
             
                 result_view.query = query
                 result_view.put()
                 fb_post_id = QueryFacebookWallpostHelper.postToWallIfNecessary(current_user, result_view, query, result_view.image_url)
             
             else:
                 result_view.put()
     
     self.response.out.write('{status: \'ok\'}')
Beispiel #2
0
    def post(self):
        cookies = h.get_default_cookies(self)
        current_user = h.get_current_user(cookies)
        query = Query(query_string = self.request.get('q'))
        
      	query.referrer = self.request.get('referrer')
      	query.url = self.request.get('u')
        query.ip_address = self.request.remote_addr
        if current_user != None:
            query.user = current_user
            if current_user.fb_user_id != None:
                query.fb_user_id = current_user.fb_user_id

        if '_pvk' in cookies and cookies['_pvk'] != None and cookies['_pvk'] != '':
            query.session_id = cookies['_pvk']
        
        query.put()
        self.response.out.write('{status: \'ok\'}')