def testProjectTitlePage(projectTitle, apiKey): #check if the api key is valid #apiKey = request.form.get('apikey') if apiKey == None or apiKey == '': return '/error=Error: bad api key' #get the user of the api key userId = databaseFunctions.getApiKeyUserId(apiKey) if userId == None or userId == '': return '/error=Error: bad api key' userInfo = databaseFunctions.getUserInfo(userId) #hit the stats #find the project projectId = databaseFunctions.getTitleProjectId(projectTitle) if projectId == None: return '/error=Error: Bad Project Name' projectInfo = databaseFunctions.getProjectInfo(projectId) databaseFunctions.addUserHit(userId, projectId) databaseFunctions.addProjectHit(userId) try: r = requests.post(projectInfo['secretUrl'], data=request.form.to_dict(flat=False)) except Exception, e: return '/error=Error: bad secret url: ' + projectInfo.get('secretUrl')
def getUserFromId(userId): #get the database function isPendingUser = False userData = databaseFunctions.getUserInfo(userId) if userData == None or userData == {}: userData = databaseFunctions.getPendingUserInfo(userId) isPendingUser = True if userData == None or userData == {}: return None print 'userData' print userData return User(userId, (not isPendingUser), False, userData.get('isAdmin'), userData['username'], userData['email'], userData['passwordHash'], userData.get('apiKey'))