예제 #1
0
 def post(self):
     """
     Add a new TodoList for User
     => POST /lists
     """
     todo_list = self.schema.load(request.get_json()).data
     current_identity.todo_lists.append(todo_list)
     current_identity.save()
     return todo_list, 200
예제 #2
0
 def post(self):
     """
     Create a Todo for a specific TodoList
     => POST /lists/<id>/todos
     """
     todo_list = TodoList.query.get(id)
     if todo_list in current_identity.todo_lists:
         todo = self.schema.load(request.get_json()).data
         todo_list.todos.append(todo)
         current_identity.save()
         return todo, 201
     else:
         return {}, 404