Ejemplo n.º 1
0
def authz_filter(q):
    return add_filter(q, {
        "or": [
            {"terms": {"$sources": list(authz.sources(authz.READ))}},
            {"terms": {"$collections": list(authz.collections(authz.READ))}}
        ]
    })
Ejemplo n.º 2
0
def authz_filter(q):
    return add_filter(
        q, {
            "or": [{
                "terms": {
                    "$sources": list(authz.sources(authz.READ))
                }
            }, {
                "terms": {
                    "$collections": list(authz.collections(authz.READ))
                }
            }]
        })
Ejemplo n.º 3
0
def result_entity(entity):
    if '_source' in entity and '_id' in entity:
        entity['_source']['id'] = entity['_id']
        entity = entity['_source']
    entity['$uri'] = url_for('entities.view', id=entity.get('id'))
    colls = entity.get('$collections', [])
    entity['$collections'] = authz.collections(authz.READ).intersection(colls)
    sources = entity.get('$sources', [])
    entity['$sources'] = authz.sources(authz.READ).intersection(sources)
    entity.pop('$text', None)
    entity.pop('$latin', None)
    for k, v in entity.items():
        if isinstance(v, (set, list, tuple)) and len(v) == 0:
            entity.pop(k)
    return entity