def blah(): userProfile = UserRepository.get(users.get_current_user()) service = ServiceRepository.get('latitude', userProfile) userProfile = UserRepository.get(users.get_current_user()) client = clients.latitude.LatitudeClient(service.access_token, service.access_secret) location = client.current_location() return json.dumps(location)
def profile_index(): currentUser = users.get_current_user() userProfile = UserRepository.get(currentUser) if userProfile == None: userProfile = UserRepository.new(currentUser) logging.info('userprofile %s' % userProfile) if(userProfile.services): isLatitudeInstalled = ServiceRepository.get('latitude', userProfile) != None isFoursquareInstalled = ServiceRepository.get('foursquare', userProfile) != None if(isLatitudeInstalled == False and isFoursquareInstalled == False): return render_template('setup_step1.html', user=currentUser, logout_url=users.create_logout_url("/")); if(isLatitudeInstalled == False and isFoursquareInstalled == True): return render_template('setup_step1.html', user=currentUser, logout_url=users.create_logout_url("/")); if(isLatitudeInstalled == True and isFoursquareInstalled == False): return render_template('setup_step2.html', user=currentUser, logout_url=users.create_logout_url("/")); if(userProfile.isPaused == True): return render_template('setup_off.html', user=currentUser, logout_url=users.create_logout_url("/")); return render_template('setup_on.html', user=currentUser, logout_url=users.create_logout_url("/"));
def fake(): lng = request.args.get('lng') lat = request.args.get('lat') accuracy = request.args.get('a') logging.warning('Faking location: %s)' % accuracy) userProfile = UserRepository.get(users.get_current_user()) service = ServiceRepository.get('latitude', userProfile) userProfile = UserRepository.get(users.get_current_user()) client = clients.latitude.LatitudeClient(service.access_token, service.access_secret) location = client.update_location(lat, lng, accuracy) return json.dumps(location)
def fs(): userProfile = UserRepository.get(users.get_current_user()) currentLocation = LocationRepository.getLatestForUser(userProfile) # 5. Get Near by venues venues = VenueRepository.getNearByVenues(userProfile, currentLocation) return json.dumps(venues)
def service_auth(service): userProfile = UserRepository.get(users.get_current_user()) if(ServiceRepository.get(service, userProfile) != None): return redirect(url_for('profile.profile_index')) callback_url = 'http://autocheckin.appspot.com/profile/setup/' + service + '/authorized' if(settings.isDebug): callback_url = 'http://localhost:8080/profile/setup/' + service + '/authorized' if service == 'latitude': consumer = oauth.Consumer(settings.latitude_key, settings.latitude_secret) request_token_url = settings.latitude_request_token_url authorize_base_url = settings.latitude_authorize_url session_key = 'oauth_latitude_request_secret' if service == 'foursquare': consumer = oauth.Consumer(settings.foursquare_key, settings.foursquare_secret) request_token_url = settings.foursquare_request_token_url authorize_base_url = settings.foursquare_authorize_url session_key = 'oauth_foursquare_request_secret' helper = oauth_helper.OAuthHelper(consumer) request_token = helper.get_request_token(request_token_url, callback_url) authorize_url = helper.get_authorize_url(request_token, authorize_base_url) session[session_key] = request_token.secret return redirect(authorize_url)
def profile_settings_save(): currentUser = users.get_current_user() userProfile = UserRepository.get(currentUser) SettingsRepository.createOrSet(userProfile, 'location-time-threshold', request.form['location-time-threshold'] ) SettingsRepository.createOrSet(userProfile, 'location-distance-threshold', request.form['location-distance-threshold']) return redirect(url_for('profile.profile_settings'))
def checkin_dummy(): userProfile = UserRepository.get(users.get_current_user()) userKey = userProfile.key() currentLocation = LocationRepository.getLatestForUser(userProfile) # 5. Add Foursquare task task = taskqueue.Task(url='/task/checkin', params={ 'userKey': userKey, 'locationKey' : currentLocation.key() }) task.add('checkin') return "Dummy check in task"
def profile_test(): currentUser = users.get_current_user() userProfile = UserRepository.get(users.get_current_user()) logging.error('userProfile %s' % userProfile.services.fetch(1)) currentLocation = LocationRepository.getLatestForUser(userProfile) timeDelta = datetime.datetime.utcnow() - currentLocation.importDate logging.info('Skipping, Location changed, but user hasn been there for time limit (timeDelta: %s)' % timeDelta) if timeDelta < datetime.timedelta(minutes=5): logging.info('6min (userkey: %s)' % timeDelta) return "" return 'none'
def profile_settings(): settings = { 'timeSetting' : '5', 'distanceSetting' : 0, 'accuracySetting' : 100 } currentUser = users.get_current_user() userProfile = UserRepository.get(currentUser) timeSetting = SettingsRepository.get(userProfile, 'location-time-threshold') distanceSetting = SettingsRepository.get(userProfile, 'location-distance-threshold') if(timeSetting != None): settings['timeSetting'] = timeSetting.value if(distanceSetting != None): settings['distanceSetting'] = distanceSetting.value return render_template('settings.html', user=currentUser, logout_url=users.create_logout_url("/"), settings = settings);
def oauth_authorized(service): if service == 'latitude': consumer = oauth.Consumer(settings.latitude_key, settings.latitude_secret) request_secret = session['oauth_latitude_request_secret'] access_token_url = settings.latitude_access_token_url if service == 'foursquare': consumer = oauth.Consumer(settings.foursquare_key, settings.foursquare_secret) request_secret = session['oauth_foursquare_request_secret'] access_token_url = settings.foursquare_access_token_url userProfile = UserRepository.get(users.get_current_user()) helper = oauth_helper.OAuthHelper(consumer) token = oauth.Token(request.args.get('oauth_token'), request_secret) verifier = request.args.get('oauth_verifier') access_token = helper.get_access_token(token, verifier, access_token_url) ServiceRepository.new(userProfile, service, access_token.key, access_token.secret) return redirect(url_for('profile.profile_index'))
def profile_start(): userProfile = UserRepository.get(users.get_current_user()) UserRepository.startUser(userProfile.key()) return redirect(url_for('profile.profile_index'))