コード例 #1
0
def getAllUsers():
    results = users.find().sort("email_address")
    output = []
    if results.count() == 0:
        output.append({'data' : 'Still no users in the database'})
    else:
        output = appendUserResults(results, output)
    return jsonify(output)
コード例 #2
0
def getSuspendedUsers():
    dbquery = {"status" : "suspended"}
    results = users.find(dbquery).sort("email_address")
    output = []
    if results.count() == 0:
        output.append({'data' : 'No suspended users were found'})
    else:
        output = appendUserResults(results, output)
    return jsonify(output)
コード例 #3
0
def lookupUser(user):
    dbquery = {"email_address" : user}
    suspensionsQuery = {"email_address" : user}
    results = users.find(dbquery)
    suspensionResults = suspensions.find(suspensionsQuery).sort("date")
    output = []
    suspensionLogs = []
    if results.count() == 0:
        output.append({'data' : 'The user was not found'})
        if suspensionResults.count() == 0:
            suspensionLogs.append({'suspension_history' : 'No suspension records were found'})
        else:
            suspensionLogs = appendSuspensionLogs(suspensionResults, suspensionLogs)
    else:
        output = appendUserResults(results, output)
        if suspensionResults.count() == 0:
            suspensionLogs.append({'suspension_history' : 'No suspension records were found'})
        else:
            suspensionLogs = appendSuspensionLogs(suspensionResults, suspensionLogs)    
    return jsonify({'user' : appendUserResults(results, output), 'suspension_history' : suspensionLogs})

# Suspend user