示例#1
0
def filter_events():
    if not request:
        abort(400)
    if request.args.get('distance') and not request.args.get('location'):
        abort (400)
    if not request.headers.get('Auth'):
        abort(401)
    try:
        ## checking auth here
        helpers.getUserFromAuthHeader(request.headers.get('Auth'))
    except:
        abort(401)

    location = request.args.get('location')
    event_name = request.args.get('event_name')
    vacancy = request.args.get('vacancy')
    distance = request.args.get('distance')
    category = request.args.get('category')
    data = engine.filterEvents(event_name, vacancy, distance, location, category)
    return jsonify(data), 200
示例#2
0
def create_interest():
    if not request or not request.form:
        abort(400)
    if not request.headers.get('Auth'):
        abort(401)
    try:
        ## checking auth here
        user = helpers.getUserFromAuthHeader(request.headers.get('Auth'))
    except:
        abort(401)
    engine.createUserInterest(user, request.form)
    return jsonify(success=True), 201
示例#3
0
def get_nearby_events():
    if not request or not request.args.get('location_coords'):
        abort(400)
    if not request.headers.get('Auth'):
        abort(401)
    try:
        ## checking auth here
        user = helpers.getUserFromAuthHeader(request.headers.get('Auth'))
    except:
        abort(401)
    events = engine.getNearbyEvents(user, request.args.get('location_coords'))
    return jsonify(events), 200
示例#4
0
def home():
    if not request:
        abort(400)
    if not request.headers.get('Auth'):
        abort(401)
    try:
        ## checking auth here
        user = helpers.getUserFromAuthHeader(request.headers.get('Auth'))
    except:
        abort(401)
    events = engine.getUserEvents(user)
    return jsonify(events), 200
示例#5
0
def get_notifications():
    if not request:
        abort(400)
    if not request.headers.get('Auth'):
        abort(401)
    try:
        ## checking auth here
        user = helpers.getUserFromAuthHeader(request.headers.get('Auth'))
    except:
        abort(401)
    data = engine.getNotifications(user)
    return jsonify(data), 200
示例#6
0
def delete_event():
    if not request or not request.args.get('event_id'):
        abort(400)
    if not request.headers.get('Auth'):
        abort(401)
    try:
        ## checking auth here
        user = helpers.getUserFromAuthHeader(request.headers.get('Auth'))
        engine.deleteEvent(user, request.args.get('event_id'))
    except:
        abort(401)
    return jsonify(success=True), 200
示例#7
0
def cancel_event_participation():
    if not request or not request.args.get('event_id'):
        abort(400)
    if not request.headers.get('Auth'):
        abort(401)
    try:
        ## checking auth here
        user = helpers.getUserFromAuthHeader(request.headers.get('Auth'))
    except:
        abort(401)
    engine.cancelUserParticipationToEvent(user, request.args.get('event_id'))
    return jsonify(success=True), 200