示例#1
0
文件: admin.py 项目: orestv/pytester
 def POST(self):
     i = web.input(topics=[], final=False)
     action = i.action
     if action == "add":
         topic_ids = [int(x) for x in i.topics]
         question_count = int(i.question_count)
         name = i.name
         final = i.final
         model.add_test(name, topic_ids, question_count, final)
     elif action == "rename":
         name = i.name
         model.rename_test(test_id, name)
     elif action == "delete":
         test_id = i.id
         model.delete_test(test_id)
示例#2
0
文件: flaskr.py 项目: orestv/pytester
def admin_test():
    if not is_admin():
        return 'login_fail'
    action = request.form['action']
    if action == 'add':
        topic_ids = request.form.getlist('topics', int)
        print topic_ids
        question_count = int(request.form['question_count'])
        name = request.form['name']
        final = request.form.get('final', False)
        model.add_test(name, topic_ids, question_count, final)
    elif action == 'delete':
        test_id = request.form['id']
        model.delete_test(test_id)
    elif action == 'rename':
        test_id = request.form['id']
        name = request.form['name']
        model.rename_test(test_id, name)
    return ''
示例#3
0
文件: flaskr.py 项目: orestv/pytester
def admin_test():
    if not is_admin():
        return "login_fail"
    action = request.form["action"]
    if action == "add":
        topic_ids = request.form.getlist("topics", int)
        print topic_ids
        question_count = int(request.form["question_count"])
        name = request.form["name"]
        final = request.form.get("final", False)
        model.add_test(name, topic_ids, question_count, final)
    elif action == "delete":
        test_id = request.form["id"]
        model.delete_test(test_id)
    elif action == "rename":
        test_id = request.form["id"]
        name = request.form["name"]
        model.rename_test(test_id, name)
    return ""