Exemple #1
0
def md_filter(query):

    subscriber_id = get_subscriber_id()
    if not MD.has_key(subscriber_id):
        return abort(400)

    # check if filter query is properly formed by request
    filters = MD[subscriber_id]["filters"].keys()
    if (query != 'q' 
        or not all(arg in filters for arg in request.args.keys())):
        return abort(400)

    li = []
    for item in MD[subscriber_id]["data"]:
        flag = True
        for key in request.args:
            # Special key for Search Box
            if key == "Search": 
                if not isFind(item, request.args[key]):
                    flag = False    
            elif item.get(key).strip().lower() not in request.args[key].strip().lower().split('||'):
                flag = False
        if flag:
            li.append(item)
            
    return jsonify( { "result" : li } )
Exemple #2
0
def get_account(account_id):
    subscriber_id = get_subscriber_id()
    if not MD.has_key(subscriber_id):
        return abort(400)
    li = []
    for item in MD[subscriber_id]["data"]:
        if item.get('Acct ID') != account_id:
            continue
        li.append(item)

    if len(li) < 1:
        return abort(404)
    return jsonify( { "result" : li } )
Exemple #3
0
def get_subscriber():
    subscriber_id = get_subscriber_id()
    if not MD.has_key(subscriber_id):
        return abort(400)
    return jsonify( { "result" : MD[subscriber_id]["data"] } )