def post(self, list_id): data = request.get_json() data["todoId"] = random.randint(1, 99999999999) data["listId"] = list_id post_user = ToDo(**data).save() output = post_user return generate_json_response(result=output)
def createToDo(): try: body = request.json name = body.get("name") description = body.get("description") tasks = body.get("tasks") toDo = ToDo(name=name, description=description) toDo.save_to_db() taskList = [] for task in tasks: tsk = Task(name=task.get("name"), toDoId=toDo.id, description=task.get("description")) tsk.save_to_db() taskList.append(tsk) return Response("Created ToDo with id {}".format(toDo.id), status=201) except Exception: return InternalServerError("Something went wrong")