Exemplo n.º 1
0
def findUser():
    usMgr = UserManager()
    query = usMgr.keepValidFieldsOnly(request.json, throw=True)
    # ignore empty values
    query = {
        k: v
        for k, v in query.items() if v is not None and v != "" and v != []
    }
    users = usMgr.getMany(query)
    return users
Exemplo n.º 2
0
def updateUser(username):
    usMgr = UserManager()
    newUserVal = usMgr.keepValidFieldsOnly(request.json, throw=True)
    # pop None / empty values
    newUserVal = {
        k: v
        for k, v in newUserVal.items() if v is not None and v != ""
    }
    success = usMgr.updateOne(username, newUserVal)
    result = {"success": success}
    return result
Exemplo n.º 3
0
def addUser():
    usMgr = UserManager()
    newUserVal = usMgr.keepValidFieldsOnly(request.json, throw=True)
    # pop None / empty values
    newUserVal = {
        k: v
        for k, v in newUserVal.items() if v is not None and v != ""
    }
    usrPk = usMgr.addOne(newUserVal)
    success = True if usrPk else False
    result = {"success": success}
    return result