Пример #1
0
 def get(self):
   user = users.get_current_user()
   if user:
     auth_token = self.request.get("oauth_token")
     if auth_token:
       credentials = constants.get_client().get_credentials(auth_token)
       old_userinfos = UserInfo.all().filter('user ='******'token'], secret = credentials['secret'], is_ready=False, is_authorized=True, last_checkin=0, last_updated=datetime.now(), color_scheme='fire', level_max=int(constants.level_const), checkin_count=0, venue_count=0)
       fetch_foursquare_data.update_user_info(userinfo)
       fetch_foursquare_data.fetch_and_store_checkins(userinfo, limit=10)
       taskqueue.add(url='/fetch_foursquare_data/all_for_user/%s' % userinfo.key())#, queue_name='initial-checkin-fetching')
       self.redirect("/")
     else:
       self.redirect(constants.get_client().get_authorization_url())
   else:
     self.redirect(users.create_login_url(self.request.uri))
Пример #2
0
 def get(self):
   welcome_data = {
     'user': '',
     'userinfo': '',
     'url': users.create_login_url(self.request.uri),
     'real_name': '',
     'photo_url': constants.default_photo,
     'is_ready': False
   }
   sidebar_data = {
     'color_scheme_dict': color_scheme.color_schemes,
     'color_scheme': constants.default_color,
   }
   map_data = {
     'citylat': constants.default_lat,
     'citylng': constants.default_lng,
     'zoom': constants.default_zoom,
     'width': constants.default_dimension,
     'height': constants.default_dimension,
   }
   user = users.get_current_user()
   if user:
     welcome_data['user'] = user
     welcome_data['url'] = users.create_logout_url(self.request.uri)
     userinfo = UserInfo.all().filter('user ='******'-created').get()
     if userinfo:
       fetch_foursquare_data.update_user_info(userinfo)
       welcome_data['userinfo'] = userinfo
       welcome_data['real_name'] = userinfo.real_name
       welcome_data['photo_url'] = userinfo.photo_url
       welcome_data['is_ready'] = userinfo.is_ready
       sidebar_data['color_scheme'] = userinfo.color_scheme
       map_data['citylat'] = userinfo.citylat
       map_data['citylng'] = userinfo.citylng
   os_path = os.path.dirname(__file__)
   self.response.out.write(template.render(os.path.join(os_path, 'templates/header.html'), {'key': constants.get_google_maps_apikey()}))
   self.response.out.write(template.render(os.path.join(os_path, 'templates/private_welcome.html'), welcome_data))
   if user and userinfo:
       self.response.out.write(template.render(os.path.join(os_path, 'templates/private_sidebar.html'), sidebar_data))
   else:
       self.response.out.write(template.render(os.path.join(os_path, 'templates/information.html'), None))
   self.response.out.write(template.render(os.path.join(os_path, 'templates/private_map.html'), map_data))
   self.response.out.write(template.render(os.path.join(os_path, 'templates/all_footer.html'), None))
Пример #3
0
 def get(self):
   welcome_data = {
     'user': '',
     'userinfo': '',
     'url': users.create_login_url(self.request.uri),
     'real_name': '',
     'photo_url': constants.default_photo,
     'is_ready': False
   }
   sidebar_data = {
     'color_scheme_dict': color_scheme.color_schemes,
     'color_scheme': constants.default_color,
   }
   map_data = {
     'citylat': constants.default_lat,
     'citylng': constants.default_lng,
     'zoom': constants.default_zoom,
     'width': constants.default_dimension,
     'height': constants.default_dimension,
   }
   foursquare_is_happy = True
   user = users.get_current_user()
   if user:
     welcome_data['user'] = user
     welcome_data['url'] = users.create_logout_url(self.request.uri)
     userinfo = UserInfo.all().filter('user ='******'-created').get()
     if userinfo:
       if userinfo.is_authorized:
         try:
           fetch_foursquare_data.update_user_info(userinfo)
         except foursquare.FoursquareRemoteException, err:
           if str(err).find('403 Forbidden') >= 0:
             foursquare_is_happy = False
           else:
             raise err
       welcome_data['userinfo'] = userinfo
       welcome_data['real_name'] = userinfo.real_name
       welcome_data['photo_url'] = userinfo.photo_url
       welcome_data['is_ready'] = userinfo.is_ready
       sidebar_data['color_scheme'] = userinfo.color_scheme
       map_data['citylat'] = userinfo.citylat
       map_data['citylng'] = userinfo.citylng
Пример #4
0
  def get(self):
    user = users.get_current_user()
    if user:
      oauth_token = self.request.get("oauth_token")

      def get_new_fs_and_credentials():
        oauth_token, oauth_secret = constants.get_oauth_strings()
        credentials = foursquare.OAuthCredentials(oauth_token, oauth_secret)
        fs = foursquare.Foursquare(credentials)
        return fs, credentials

      if oauth_token:
        old_userinfos = UserInfo.all().filter('user ='******'token =', oauth_token).get()
        
        try:
          user_token = fs.access_token(oauth.OAuthToken(apptoken.token, apptoken.secret))
          credentials.set_access_token(user_token)
          userinfo = UserInfo(user = user, token = credentials.access_token.key, secret = credentials.access_token.secret, is_ready=False, is_authorized=True, last_checkin=0, last_updated=datetime.now(), color_scheme='fire', level_max=int(constants.level_const), checkin_count=0, venue_count=0)
        except DownloadError, err:
          if str(err).find('ApplicationError: 5') >= 0:
            pass # if something bad happens on OAuth, then it currently just redirects to the signup page
                 #TODO find a better way to handle this case, but it's not clear there is a simple way to do it without messing up a bunch of code
          else:
            raise err
        try:
          fetch_foursquare_data.update_user_info(userinfo)
          fetch_foursquare_data.fetch_and_store_checkins(userinfo, limit=10)
          taskqueue.add(url='/fetch_foursquare_data/all_for_user/%s' % userinfo.key())
        except foursquare.FoursquareRemoteException, err:
          if str(err).find('403 Forbidden') >= 0:
            pass # if a user tries to sign up while my app is blocked, then it currently just redirects to the signup page
                 #TODO find a better way to handle this case, but it's not clear there is a simple way to do it without messing up a bunch of code
          else:
            raise err
        except DownloadError:
          pass #TODO make this better, but I'd rather throw the user back to the main page to try again than show the user an error.