Ejemplo n.º 1
0
def metadata():
    enable_cache(server_side=False)
    schemata = {}
    for schema_id, schema in resolver.store.items():
        if not schema_id.endswith('#'):
            schema_id = schema_id + '#'
        schemata[schema_id] = {
            'id': schema_id,
            'title': schema.get('title'),
            'faIcon': schema.get('faIcon'),
            'plural': schema.get('plural', schema.get('title')),
            'description': schema.get('description'),
            'inline': schema.get('inline', False)
        }
    return jsonify({
        'status': 'ok',
        'app': {
            'title': get_app_title(),
            'url': get_app_url(),
            'samples': get_config('SAMPLE_SEARCHES')
        },
        'fields': Metadata.facets(),
        'categories': Collection.CATEGORIES,
        'countries': COUNTRY_NAMES,
        'languages': LANGUAGE_NAMES,
        'schemata': schemata
    })
Ejemplo n.º 2
0
def metadata():
    enable_cache(server_side=False)
    schemata = {}
    for schema_id, schema in resolver.store.items():
        if not schema_id.endswith('#'):
            schema_id = schema_id + '#'
        schemata[schema_id] = {
            'id': schema_id,
            'title': schema.get('title'),
            'faIcon': schema.get('faIcon'),
            'plural': schema.get('plural', schema.get('title')),
            'description': schema.get('description'),
            'inline': schema.get('inline', False)
        }
    return jsonify({
        'status': 'ok',
        'app': {
            'title': get_app_title(),
            'url': get_app_url(),
            'samples': get_config('SAMPLE_SEARCHES')
        },
        'fields': Metadata.facets(),
        'categories': Collection.CATEGORIES,
        'countries': COUNTRY_NAMES,
        'languages': LANGUAGE_NAMES,
        'schemata': schemata
    })
Ejemplo n.º 3
0
def check_role_alerts(role):
    alerts = Alert.by_role(role).all()
    if not len(alerts):
        return
    log.info('Alerting %r, %d alerts...', role, len(alerts))
    for alert in alerts:
        results = alert_query(alert)
        if results['total'] == 0:
            continue
        log.info('Found: %d new results for: %r', results['total'],
                 alert.label)
        alert.update()
        try:
            subject = '%s (%s new results)' % (alert.label, results['total'])
            html = render_template('alert.html',
                                   alert=alert,
                                   results=results,
                                   role=role,
                                   qs=make_document_query(alert),
                                   app_title=get_config('APP_TITLE'),
                                   app_url=get_app_url())
            notify_role(role, subject, html)
        except Exception as ex:
            log.exception(ex)
    db.session.commit()
Ejemplo n.º 4
0
def reconcile_index():
    domain = get_app_url().strip('/')
    api_key = request.auth_role.api_key if authz.logged_in() else None
    preview_uri = entity_link('{{id}}') + '&preview=true&api_key=%s' % api_key
    meta = {
        'name': get_app_title(),
        'identifierSpace': 'http://rdf.freebase.com/ns/type.object.id',
        'schemaSpace': 'http://rdf.freebase.com/ns/type.object.id',
        'view': {'url': entity_link('{{id}}')},
        'preview': {
            'url': preview_uri,
            'width': 600,
            'height': 300
        },
        'suggest': {
            'entity': {
                'service_url': domain,
                'service_path': url_for('reconcile_api.suggest_entity',
                                        api_key=api_key)
            },
            'type': {
                'service_url': domain,
                'service_path': url_for('reconcile_api.suggest_type')
            },
            'property': {
                'service_url': domain,
                'service_path': url_for('reconcile_api.suggest_property')
            }
        },
        'defaultTypes': [{
            'id': DEFAULT_TYPE,
            'name': 'Persons and Companies'
        }]
    }
    return jsonify(meta)
Ejemplo n.º 5
0
def check_role_alerts(role):
    alerts = Alert.by_role(role).all()
    if not len(alerts):
        return
    log.info('Alerting %r, %d alerts...', role, len(alerts))
    for alert in alerts:
        results = alert_query(alert)
        if results['total'] == 0:
            continue
        log.info('Found: %d new results for: %r', results['total'],
                 alert.label)
        alert.update()
        try:
            subject = '%s (%s new results)' % (alert.label, results['total'])
            html = render_template('alert.html', alert=alert, results=results,
                                   role=role, qs=make_document_query(alert),
                                   app_title=get_app_title(),
                                   app_url=get_app_url())
            notify_role(role, subject, html)
        except Exception as ex:
            log.exception(ex)
    db.session.commit()
Ejemplo n.º 6
0
def send_welcome_mail(role):
    subject = 'Welcome to Aleph'
    html = render_template('mail/welcome_mail.html', app_url=get_app_url())
    notify_role(role, subject, html)
Ejemplo n.º 7
0
def entity_link(id):
    return urljoin(get_app_url(), '/search?entity=%s' % id)