Beispiel #1
0
def convert_sources(facet):
    output = {'values': []}
    ids = [b.get('key') for b in facet.get('buckets', [])]
    labels = Source.all_labels(ids=ids)
    for bucket in facet.get('buckets', []):
        key = bucket.get('key')
        output['values'].append({
            'id': key,
            'label': labels.get(key, key),
            'count': bucket.get('doc_count')
        })
    return output
Beispiel #2
0
def convert_sources(facet):
    output = {'values': []}
    ids = [b.get('key') for b in facet.get('buckets', [])]
    sources = Source.all_by_ids(ids).all()
    for bucket in facet.get('buckets', []):
        key = bucket.get('key')
        for source in sources:
            if source.id != key:
                continue
            output['values'].append({
                'id': key,
                'label': source.label,
                'category': source.category,
                'count': bucket.get('doc_count')
            })
    return output
Beispiel #3
0
def source_slug_available(value):
    from aleph.model.source import Source
    existing = Source.by_slug(value)
    return existing is None
Beispiel #4
0
def source_slug_available(value):
    from aleph.model.source import Source
    existing = Source.by_slug(value)
    return existing is None