示例#1
0
文件: quest.py 项目: tjpumis/alchemy
def get_saveforlater(quest_sn: int):

    saveforlater = drecall(ts_quest_saveforlater(quest_sn=quest_sn))
    if not saveforlater:
        return None

    return saveforlater
示例#2
0
文件: quest.py 项目: tjpumis/alchemy
def put_saveforlater(quest_sn: int, json_arg):
    """创建或保存试题"""

    status = bool(json_arg['status']) # true or false
    if status:
        old_sfl = drecall(ts_quest_saveforlater(quest_sn=quest_sn))

        new_sfl = ts_quest_saveforlater(quest_sn=quest_sn)

        new_sfl.updated_ts = datetime.utcnow() if status else None
        dmerge(new_sfl, old_sfl)

        return new_sfl
    else:
        dbc << """
        DELETE FROM ts_quest_saveforlater
        WHERE quest_sn = %(quest_sn)s
        """
        dbc << dict(quest_sn=quest_sn)

        return None