def room_get_detail(room_id): service = RoomService(db) room = service.get_detail(room_id) if room: return jsonify(room.json()) else: abort(404)
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)
def room_post(): service = RoomService(db) room = service.add(request.json) if room: return jsonify(RoomSchema().dump(room).data) else: raise BadRequest()
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)
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)
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)
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], })
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], })
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], })