示例#1
0
def room_get_detail(room_id):
    service = RoomService(db)
    room = service.get_detail(room_id)
    if room:
        return jsonify(room.json())
    else:
        abort(404)
示例#2
0
def message_detail(room_id, message_id):
    service = RoomService(db)
    message = service.get_message(room_id, message_id)
    if message:
        return jsonify(message.json(verbose=True))
    else:
        abort(400)
示例#3
0
def room_post():
    service = RoomService(db)
    room = service.add(request.json)
    if room:
        return jsonify(RoomSchema().dump(room).data)
    else:
        raise BadRequest()
示例#4
0
def qa_detail_reject(room_id, qa_id):
    service = RoomService(db)
    qa = service.reject_qa(room_id, qa_id)
    if qa:
        return jsonify(qa.json(verbose=True))
    else:
        abort(400)
示例#5
0
def add_message(room_id):
    service = RoomService(db)
    data = request.json
    data['room_id'] = room_id
    message = service.add_message(room_id, request.json)
    if message:
        return jsonify(message.json(verbose=True))
    else:
        abort(400)
示例#6
0
def add_qa(room_id):
    service = RoomService(db)
    data = request.json
    data['room_id'] = room_id
    qa = service.add_qa(room_id, request.json)
    if qa:
        return jsonify(qa.json(verbose=True))
    else:
        abort(400)
示例#7
0
def room_get():
    service = RoomService(db)
    data = {
        'major': request.args.get('major', None),
        'minor': request.args.get('minor', None),
    }
    rooms = service.get(data)
    if rooms.count() == 1L:
        return jsonify(rooms[0].json())
    else:
        return jsonify({
            'results': [room.json() for room in rooms],
        })
示例#8
0
def messages_list(room_id):
    service = RoomService(db)
    messages = service.list_messages(room_id, request.args)
    return jsonify({
        'results': [message.json() for message in messages],
    })
示例#9
0
def qas_list(room_id):
    service = RoomService(db)
    qas = service.list_qas(room_id, request.args)
    return jsonify({
        'results': [qa.json() for qa in qas],
    })