def add_participant(event_id): if enrollments_service.add_participant(event_id, get_jwt_identity()): result = json_response.build_success() status = 200 else: result = json_response.build_error() status = 404 return jsonify(result), status
def profile(participant_id): participant = participants_service.get_by_id(participant_id) if participant is None: result = json_response.build_error() status = 404 else: result = json_response.build_participant(participant) status = 200 return jsonify(result), status
def location(location_id): location_item = locations_service.get_by_id(location_id) if location_item is None: result = json_response.build_error() status = 404 else: result = json_response.build_location(location_item) status = 200 return jsonify(result), status
def event_type(type_id): event_type_item = event_types_service.get_by_id(type_id) if event_type_item is None: result = json_response.build_error() status = 404 else: result = json_response.build_event_type(event_type_item) status = 200 return jsonify(result), status
def event_category(category_id): category = event_categories_service.get_by_id(category_id) if category is None: result = json_response.build_error() status = 404 else: result = json_response.build_event_category(category) status = 200 return jsonify(result), status
def register(): participant_password = participants_service.generate_password(8) participant_id = participants_service.create(request.args, participant_password) if participant_id is None: result = json_response.build_error() status = 422 else: participant = participants_service.get_by_id(participant_id) result = json_response.build_new_participant(participant, participant_password) status = 200 return jsonify(result), status
def login(): participant_id = participants_service.login(request.args) if participant_id is None: result = json_response.build_error() status = 422 else: participant = participants_service.get_by_id(participant_id) access_token = participants_service.create_participant_access_token( participant_id) result = json_response.build_auth_participant(participant, access_token) status = 200 return jsonify(result), status