Ejemplo n.º 1
0
def create_scene():
    try:
        scene = com_post(db, Scene)
    except Exception as e:
        current_app.logger.error("[scene][post] fail expection: {}".format(e))
        return InvalidMessage(str(e), 500)
    data = model_helper.obj_to_dict(scene)
    return return_data(data, 201)
Ejemplo n.º 2
0
def get_question(id):
    try:
        question = com_get(Question, id=id)
    except Exception as e:
        current_app.logger.error("[question][get] fail expection: {}".format(e))
        return InvalidMessage(str(e), 500)
    data = model_helper.obj_to_dict(question)
    return return_data(data, 200)
Ejemplo n.º 3
0
def get_label(id):
    try:
        label = com_get(Label, id=id)
    except Exception as e:
        current_app.logger.error("[label][get] fail expection: {}".format(e))
        return InvalidMessage(str(e), 500)
    data = model_helper.obj_to_dict(label)
    return return_data(data, 200)
Ejemplo n.º 4
0
def create_label():
    try:
        label = com_post(db, Label)
    except Exception as e:
        current_app.logger.error("[label][post] fail expection: {}".format(e))
        return InvalidMessage(str(e), 500)
    data = model_helper.obj_to_dict(label)
    return return_data(data, 201)
Ejemplo n.º 5
0
def get_scene(id):
    try:
        scene = com_get(Scene, id=id)
    except Exception as e:
        current_app.logger.error("[scene][get] fail expection: {}".format(e))
        return InvalidMessage(str(e), 500)
    data = model_helper.obj_to_dict(scene)
    return return_data(data, 200)
Ejemplo n.º 6
0
def create_paper_question():
    try:
        paper_question = com_post(db, PaperQuestion)
    except Exception as e:
        current_app.logger.error(
            "[paper_question][post] fail expection: {}".format(e))
        return InvalidMessage(str(e), 500)
    data = model_helper.obj_to_dict(paper_question)
    return return_data(data, 201)
Ejemplo n.º 7
0
def get_user_head(id):
    try:
        user_head = com_get(UserHead, id=id)
    except Exception as e:
        current_app.logger.error(
            "[user_head][get] fail expection: {}".format(e))
        return InvalidMessage(str(e), 500)
    data = model_helper.obj_to_dict(user_head)
    return return_data(data, 200)
Ejemplo n.º 8
0
def create_user_head():
    try:
        user_head = com_post(db, UserHead)
    except Exception as e:
        current_app.logger.error(
            "[user_head][post] fail expection: {}".format(e))
        return InvalidMessage(str(e), 500)
    data = model_helper.obj_to_dict(user_head)
    return return_data(data, 201)
Ejemplo n.º 9
0
def create_question():
    try:
        questions = com_posts(db, Question)
    except Exception as e:
        current_app.logger.error("[questions][post] fail expection: {}".format(e))
        return InvalidMessage(str(e), 500)
    for question in questions:
        paper_helper.compute_score(question.paper.head)
    try:
        # 同步数据到数据库
        db.session.commit()
    except Exception as e:
        current_app.logger.error("{} model init exception: {}".format(Question, e))
        raise e
    datas = []
    for question in questions:
        data_obj = model_helper.obj_to_dict(question)
        datas.append(data_obj)
    return return_data(datas, 201)