def testCreateUsers(self): DbManager().createUsers() users = User.query().fetch(10) self.assertEqual(10, len(users)) # test the description: nickName=users[1].nickName self.assertEqual(nickName, '*****@*****.**')
def wrapper(): jwt = request.json.get('jwt') this_user = User.decode_jwt(jwt) if this_user == None: return jsonify({ "success" : False }) return func(this_user)
def login_user(): req_json = request.json username = req_json.get('username') password = req_json.get('password') user = User.login(username, password) if user is None: return jsonify({'success': False}) return jsonify({'user': user.serialize(), 'success': True})
def create_user(): req_json = request.json username = req_json.get('username') password = req_json.get('password') password_confirm = req_json.get('password_confirm') user = User.create_user(username, password, password_confirm) if user is None: return jsonify({'success': False}) return jsonify({'user': user.serialize(), 'success': True})
def updateMemberLevel(self, nickName, level): out = '' q = User.query(User.nickName == nickName) users = q.fetch() user = users[0] if user != None: user.level = level user.put() out = 'member level updated' else: out = 'no member found' return out
def saveUser(self, data): response = {'info':'','error':'true','message':''} user = User(nickName=data['nickName'], userId=data['userId'], level='guest') if data.has_key('name'): user.name = data['name'] if data.has_key('level'): user.level = data['level'] q = User.query() users = q.fetch() isEmailFound=False # check the already existing users: for i in range(0, len(users)): if users[i].nickName== user.nickName: isEmailFound = True break if isEmailFound == True: response['error']='true' response['message']='User with this email already exists.' else: # create user: user.put() response['error']='false' response['message']='New User created successfully' return response
def isUserAdmin(self, nickName, level): q = User.query(User.nickName == nickName) users = q.fetch() isNickNameFound=False isUserAdmin = False user = users[0] if user != None: if user.level == level: isUserAdmin = True # check the already existing users: ''' for i in range(0, len(users)): if users[i].nickName== nickName: isNickNameFound = True if users[i].level == level: isUserAdmin = True break ''' return isUserAdmin
def getMemberByNickName(self, nickName): q = User.query(User.nickName == nickName) users = q.fetch() return users[0]
def getMembers(self): q = User.query() users, nextCursor, more = q.fetch_page(20) return users
def getUsers(self): """ gets users list from google data store""" q = User.query() users = q.fetch() return users