示例#1
0
def get_task(task_id):
	#task = [task for task in tasks if task["id"] == task_id]
	
	db.db.connect()
	try:
		task = db.get_task(task_id)
	except:
		abort(404)
	db.db.close()

	return jsonify({"task": make_public(task)})
示例#2
0
def task():
    if not session.get('logged_in', False):
        return redirect('/')

    team_id = session['team_id']
    if request.method == 'GET':
        stage = get_task(team_id).stage
        if stage > 1000:
            user = get_user(team_id)
            return user.flag
        else:
            answer, task_body = generate()
            update_answer(team_id, answer)
            return render_template('task.html', stage=stage, task=task_body)
    else:
        task = get_task(team_id)
        answer = str(request.form['answer'])
        if answer == task.answer:
            update_stage(team_id, task.stage + 1)
        return redirect('/task')
示例#3
0
def update(id):
    if request.method == 'POST':
        new_task = request.form.get('content')

        if not new_task:
            return render_template('apology.html', msg='No task provided!'), 404

        database.update_task(id, new_task)
        return redirect('/')

    else:
        task = database.get_task(task_id=id)
        return render_template('update.html', task=task)
示例#4
0
def update_task(task_id):
    task = database.get_task(CONNECTION, task_id)
    print(task)
    if len(task) == 0:
        abort(404)
    if not request.json:
        abort(400)
    if 'title' in request.json and not isinstance(request.json['title'], str):
        abort(400)
    if 'description' in request.json and \
            not isinstance(request.json['description'], str):
        abort(400)
    if 'done' in request.json and type(request.json['done']) is not bool:
        abort(400)
    task[0]['title'] = request.json.get('title', task[0]['title'])
    task[0]['description'] = request.json.get('description',
                                              task[0]['description'])
    task[0]['status'] = request.json.get('status', task[0]['status'])
    database.update_task(CONNECTION, task[0])
    return jsonify({'task': make_public_task(task[0])})
示例#5
0
def complete(request, list_id, series_id, task_id):
    task = database.get_task(list_id, series_id, task_id)
    task.complete()
    return redirect('home')
示例#6
0
def postpone(request, list_id, series_id, task_id):
    task = database.get_task(list_id, series_id, task_id)
    task.postpone()
    return redirect('home')
示例#7
0
def edit(request, list_id, series_id, task_id):
    task = database.get_task(list_id, series_id, task_id)
    return render_to_response('edit.html', {'task': task}, RequestContext(request))
示例#8
0
def edit_item(no):
    cur_data = database.get_task(no)
    return template('edit_task', old=cur_data, no=no)
示例#9
0
def get_task(task_id):
    task = database.get_task(CONNECTION, task_id)
    if len(task) == 0:
        abort(404)
    return jsonify({'task': make_public_task(task[0])})
示例#10
0
def delete_task(task_id):
    task = database.get_task(CONNECTION, task_id)
    if len(task) == 0:
        abort(404)
    database.delete_task(CONNECTION, task_id)
    return jsonify({'result': True})