Esempio n. 1
0
def update_download_coverage(user_token):
    user = User.by_authproxy_token(user_token)
    if not user:
        json_abort(401, 'unknown user token')

    signals.features_updated.send(user)

    return jsonify({'sucess': True})
Esempio n. 2
0
def update_download_coverage(user_token):
    user = User.by_authproxy_token(user_token)
    if not user:
        json_abort(401, 'unknown user token')

    signals.features_updated.send(user)

    return jsonify({'sucess': True})
Esempio n. 3
0
def log(user_token):
    if request.headers['content-type'] != 'application/json':
        json_abort(406, "request content-type not application/json")

    try:
        log_record = json.loads(request.data)
    except (TypeError, ValueError):
        json_abort(400, 'invalid JSON')

    try:
        user = User.by_authproxy_token(user_token)
        if not user:
            json_abort(401, 'unknown user token')

        if user.email != log_record['user']:
            json_abort(401, 'user token does not match user email')

        time = log_record['time']
        action = log_record['action']
    except KeyError, ex:
        json_abort(400, 'missing %s in log record' % ex)
Esempio n. 4
0
def log(user_token):
    if request.headers['content-type'] != 'application/json':
        json_abort(406, "request content-type not application/json")

    try:
        log_record = json.loads(request.data)
    except (TypeError, ValueError):
        json_abort(400, 'invalid JSON')

    try:
        user = User.by_authproxy_token(user_token)
        if not user:
            json_abort(401, 'unknown user token')

        if user.email != log_record['user']:
            json_abort(401, 'user token does not match user email')

        time = log_record['time']
        action = log_record['action']
    except KeyError, ex:
        json_abort(400, 'missing %s in log record' % ex)
Esempio n. 5
0
def log(user_token):
    if request.headers["content-type"] != "application/json":
        json_abort(406, "request content-type not application/json")

    try:
        log_record = json.loads(request.data)
    except (TypeError, ValueError):
        json_abort(400, "invalid JSON")

    try:
        user = User.by_authproxy_token(user_token)
        if not user:
            json_abort(401, "unknown user token")

        if user.email != log_record["user"]:
            json_abort(401, "user token does not match user email")

        time = log_record["time"]
        action = log_record["action"]
    except KeyError, ex:
        json_abort(400, "missing %s in log record" % ex)
Esempio n. 6
0
        user = User.by_authproxy_token(user_token)
        if not user:
            json_abort(401, 'unknown user token')

        if user.email != log_record['user']:
            json_abort(401, 'user token does not match user email')

        time = log_record['time']
        action = log_record['action']
    except KeyError, ex:
        json_abort(400, 'missing %s in log record' % ex)
    log = Log(user=user, time=time, action=action)

    if 'geometry' in log_record:
        if log_record['geometry']['type'] != 'MultiPolygon':
            json_abort(400, "geometry not a MultiPolygon")
        geom = asShape(log_record['geometry'])
        wkb = from_shape(geom, srid=3857)
        log.geometry = ST_Transform(wkb, 4326)

    log.source = log_record.get('source')
    log.layer = log_record.get('layer')
    log.zoom_level_start = log_record.get('zoom_level_start')
    log.zoom_level_end = log_record.get('zoom_level_end')
    log.refreshed = log_record.get('refreshed')
    log.mapping = log_record.get('mapping')
    log.format = log_record.get('format')
    log.srs = log_record.get('srs')

    try:
        db.session.add(log)
Esempio n. 7
0
        user = User.by_authproxy_token(user_token)
        if not user:
            json_abort(401, 'unknown user token')

        if user.email != log_record['user']:
            json_abort(401, 'user token does not match user email')

        time = log_record['time']
        action = log_record['action']
    except KeyError, ex:
        json_abort(400, 'missing %s in log record' % ex)
    log = Log(user=user, time=time, action=action)

    if 'geometry' in log_record:
        if log_record['geometry']['type'] != 'MultiPolygon':
            json_abort(400, "geometry not a MultiPolygon")
        geom = asShape(log_record['geometry'])
        wkb = from_shape(geom, srid=3857)
        log.geometry = ST_Transform(wkb, 4326)

    log.source = log_record.get('source')
    log.layer = log_record.get('layer')
    log.zoom_level_start = log_record.get('zoom_level_start')
    log.zoom_level_end = log_record.get('zoom_level_end')
    log.refreshed = log_record.get('refreshed')
    log.mapping = log_record.get('mapping')
    log.format = log_record.get('format')
    log.srs = log_record.get('srs')

    try:
        db.session.add(log)