Пример #1
0
def login(username):
    '''A function that takenano s in a username and returns a user object'''
    _log.info('Attempting to retrieve user from database')
    query_dict = {'username': username}
    user_dict = _scl.users.find_one(query_dict)
    _log.debug(user_dict)
    return User.from_dict(user_dict) if user_dict else None
Пример #2
0
def get_teachers():
    dict_list = _scl.users.find({'role': 'teacher'})
    return [User.from_dict(user) for user in dict_list]
Пример #3
0
def get_students():
    dict_list = _scl.users.find({'role': 'student'})
    return [User.from_dict(user) for user in dict_list]
Пример #4
0
def get_users():
    '''Read all the users from the collection'''
    _log.info('Attempting to retrieve all users from database')
    dict_list = _scl.users.find()
    return [User.from_dict(user) for user in dict_list]
Пример #5
0
def get_requirements(requirements):
    '''Gets all requirements'''
    _log.info('Attempting to retrieve all users from database')
    dict_list = _scl.users.find({'username': requirements})
    return [User.from_dict(user) for user in dict_list]
Пример #6
0
def get_user_by_id(db_id: int):
    '''Returns a user by their id'''
    return User.from_dict(_scl.users.find_one({'_id': db_id}))