Пример #1
0
 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, '*****@*****.**') 
Пример #2
0
	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)
Пример #3
0
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})
Пример #4
0
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})
Пример #5
0
 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
Пример #6
0
 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
Пример #7
0
 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 
Пример #8
0
 def getMemberByNickName(self, nickName):
     q = User.query(User.nickName == nickName)
     users = q.fetch()
     return users[0] 
Пример #9
0
 def getMembers(self):
     q = User.query()
     users, nextCursor, more = q.fetch_page(20)
     return users 
Пример #10
0
 def getUsers(self):
     """ gets users list from google data store"""
     q = User.query()
     users = q.fetch()
     return users