예제 #1
0
def create_task(tasklist_id):
	"""
	POST /<tasklist_id>/tasks - Create a task associating it to a tasklist

	PARAMETERS:
		tasklist_id - Id of existent TaskList
		model
			title - Title of the task
			completed - Status of the task
	"""
	task = request.json['model']
	if TaskValidator.valid(task):
		task = models.create_task(tasklist_id, task['title'], task['completed'])
		return render_json(to_json(task))
	else:
		return render_json('{"error": "Invalid task parameters"}'), 400
예제 #2
0
def update_task(tasklist_id, task_id):
	"""
	PUT /<tasklist_id>/tasks/<task_id> - Modify the status of a Task that belongs to a TaskList.

	PARAMETERS:
		tasklist_id - Id of tasklist
		task_id - Id of the task
		model
			title - Title of the task
			completed - Status of the task
	"""
	try:
		task = request.json['model']
		if TaskValidator.valid(task):
			task = models.update_task(task_id, task['title'], task['completed'])
			return render_json(to_json(task))
		else:
			return render_json('{"error": "Invalid parameters"}'), 400
	except TaskNotFoundException as e:
		return render_json('{"error": %s }', e.message), 404