Beispiel #1
0
def show(location_id):
    schema = LocationSchema()
    location = Location.get(id=location_id)

    if not location:
        abort(404)

    return schema.dumps(location)
Beispiel #2
0
def delete(location_id):
    location = Location.get(id=location_id)

    if not location:
        abort(404)

    location.delete()
    db.commit()

    return '', 204
Beispiel #3
0
def update(location_id):
    schema = LocationSchema()
    location = Location.get(id=location_id)

    if not location:
        abort(404)

    try:
        data = schema.load(request.get_json())
        location.set(**data)
        db.commit()
    except ValidationError as err:
        return jsonify({
            'message': 'Validation failed',
            'errors': err.messages
        }), 422

    return schema.dumps(location)