def decorated_function(*args, **kwargs):
        type_error = ('Provide a Json', 415)
        header_values = ['*/*', 'application/json']
        header_keys = ['Accept', 'Content-Type']
        header = request.headers
        rm = request.method
        methods = ['POST', 'PUT', 'PATCH']
        if rm in methods:
            if not request.data:
                return create_response(*type_error)
            if not all(h in header for h in header_keys):
                return create_response(*type_error)
            if not all(header[h] in header_values for h in header_keys):
                return create_response(*type_error)

        return func(*args, **kwargs)
def get_all_occurrences():
    user = request.args.get('user')
    occurrence_type = request.args.get('occurrence_type')

    response, status = controller.get_all_occurrences(user, occurrence_type)

    return create_response(response, status)
def get_coordinates():
    state = request.args.get('state')

    if request.method == 'GET':
        response, status = controller.get_all_coordinates(state)

    return create_response(response, status)
示例#4
0
def delete_get_neighborhood(id_neighborhood):
    if request.method == 'DELETE':
        response, status = controller.delete_neighborhood(id_neighborhood)
    elif request.method == 'GET':
        response, status = controller.get_one_neighborhood(id_neighborhood)

    return create_response(response, status)
示例#5
0
def get_all_neighborhoods():
    city = request.args.get('city')
    state = request.args.get('state')

    response, status = controller.get_all_neighborhoods(city, state)

    return create_response(response, status)
def get_ratings():
    user = request.args.get('user')
    neighborhood = request.args.get('neighborhood')

    response, status = controller.get_all_ratings(user, neighborhood)

    return create_response(response, status)
def get_crimes():
    per_capita = request.headers.get('per_capita')

    if request.method == 'GET':
        response, status = controller.get_all_crimes(request.args, per_capita)

    return create_response(response, status)
示例#8
0
def delete_patch_user(user_username):
    if request.method == 'DELETE':
        response, status = controller.delete_user(user_username)

    elif request.method == 'PATCH':
        response, status = controller.update_user(user_username, request.json)

    return create_response(response, status)
示例#9
0
def get_post_user():
    if request.method == 'GET':
        response, status = controller.get_all_users()

    elif request.method == 'POST':
        response, status = controller.create_user(request.json)

    return create_response(response, status)
def rating_by_id(username, id_rating):
    if request.method == 'DELETE':
        response, status = controller.delete_rating(id_rating, username)

    elif request.method == 'PATCH':
        response, status = controller.update_rating(id_rating, request.json,
                                                    username)

    return create_response(response, status)
def delete_patch_occurrence(username, occurrence_id):
    if request.method == 'DELETE':
        response, status = controller.delete_occurrence(
            occurrence_id, username)

    elif request.method == 'PATCH':
        response, status = controller.update_occurrence(
            occurrence_id, request.json, username)

    return create_response(response, status)
示例#12
0
def post_send_notifications(username):
    response, status = controller.send_notifications_near_occcurrences(
        request.json, username)

    return create_response(response, status)
示例#13
0
def user_by_username(user_username):
    response, status = controller.get_one_user(user_username)

    return create_response(response, status)
def post_rating(username, id_neighborhood):
    response, status = controller.create_rating(request.json, username,
                                                id_neighborhood)

    return create_response(response, status)
def occurrence_by_id(occurrence_id):
    response, status = controller.get_one_occurrence(occurrence_id)

    return create_response(response, status)
def make_auth():
    response, status = controller.authentication(request.authorization)

    return create_response(response, status)
def post_occurrence(username):
    response, status = controller.create_occurrence(username, request.json)

    return create_response(response, status)
示例#18
0
def get_favorite_places_by_user(username):
    response, status = controller.get_favorite_places(username)

    return create_response(response, status)
示例#19
0
def delete_favorite_place_by_id(username, id_place):
    response, status = controller.delete_favorite_place(username, id_place)

    return create_response(response, status)
示例#20
0
def post_favorite_place(username):
    response, status = controller.create_favorite_place(
        username, request.json)

    return create_response(response, status)
示例#21
0
def get_post_rubric():
    response, status = controller.create_neighborhood(request.json)

    return create_response(response, status)
def get_rating_by_id(id_rating):
    response, status = controller.get_one_rating(id_rating)

    return create_response(response, status)