예제 #1
0
def searchPersons():
    retornar = {"templates": [], "doc_ids": []}
    templates = list(personas.find({}, {'doc_id', 'template_recognition'}))
    for elementos in templates:
        for (index, elemento) in enumerate(elementos['template_recognition']):
            retornar["templates"].append([float(i) for i in elemento])
            retornar["doc_ids"].append(elementos['doc_id'])
    return (retornar)
예제 #2
0
def get_personas():
    p = []
    for _p in list(
            personas.find({},
                          {'_id', 'doc_id', 'category', 'status', 'client'})):
        categ = list(categorias.find({'_id': _p['category']}))
        _p['category'] = categ[0]['descripcion'] if len(categ) > 0 else str(
            _p['category'])
        stat = list(estatus.find({'_id': _p['status']}))
        _p['status'] = stat[0]['descripcion'] if len(stat) > 0 else str(
            _p['status'])
        _p['_id'] = str(_p['_id'])
        p.append(_p)

    return jsonify(p)
예제 #3
0
def getstatus():
    data = request.json
    if request.method == 'GET':
        pers = []
        filtros = {}

        if request.args.get('category'):
            filtros['category'] = ObjectId(request.args.get('category'))
        if request.args.get('status'):
            filtros['status'] = ObjectId(request.args.get('status'))

        for c in list(personas.find(filtros)):
            c['_id'] = str(c['_id'])
            categ = list(categorias.find({'_id': c['category']}))
            c['category'] = categ[0]['descripcion'] if len(categ) > 0 else str(
                c['category'])
            stat = list(categorias.find({'_id': c['status']}))
            c['status'] = categ[0]['descripcion'] if len(stat) > 0 else str(
                c['status'])
            pers.append(c)

        return jsonify(pers)