def entity_watchlists(q, aggs, args, filters): """ Filter entities, facet for watchlists. """ entities = args.getlist('entity') watchlists = [] readable = authz.watchlists(authz.READ) for watchlist_id in args.getlist('watchlist'): if authz.watchlist_read(watchlist_id): watchlists.append(watchlist_id) flt = { 'or': [ { 'terms': {'entities.watchlist_id': watchlists} }, { 'and': [ { 'terms': {'entities.watchlist_id': readable}, 'terms': {'entities.entity_id': entities}, } ] } ] } aggs['entities'] = { 'nested': { 'path': 'entities' }, 'aggs': { 'inner': { 'filter': flt, 'aggs': { 'entities': { 'terms': {'field': 'entity_id', 'size': 100} } } } } } return q
def view(id): authz.require(authz.watchlist_read(id)) watchlist = obj_or_404(Watchlist.by_id(id)) etag_cache_keygen(watchlist) return jsonify(watchlist)
def view(id): entity = obj_or_404(Entity.by_id(id)) authz.require(authz.watchlist_read(entity.watchlist_id)) return jsonify(entity)