Esempio n. 1
0
 def delete(self, todo_id):
     """ This method will delete todo from database"""
     todo = self.get_by_id(todo_id)
     todo.remove()
     return create_response(200,
                            todo_id,
                            msg="Data todo has removed permanently")
Esempio n. 2
0
    def get(self, todo_id):
        """ This method will handle to restore todo from trash room"""

        todo = self.get_by_id(todo_id)
        todo.restore()
        data = self.todo_schema.dump(todo).data
        return create_response(200, data, "Success restore data todo")
Esempio n. 3
0
    def post(self):
        """ This method will handle post data to create new todo data"""

        todo = self.new_todo(request.get_json(force=True))
        todo.save()
        return create_response(201,
                               self.todo_schema.dump(todo).data,
                               "Success create todo data")
Esempio n. 4
0
    def patch(self, todo_id):
        """ This method will handle to add todo to trash room"""

        todo = self.get_by_id(todo_id)
        todo.delete()
        return create_response(200,
                               self.todo_schema.dump(todo).data,
                               "Success add todo to trash room")
Esempio n. 5
0
    def get(self):
        """ This method will handle all get data of list todo"""

        return create_response(
            200,
            self.todos_schema.dump(
                self.get_all_todo(self.search, self.page,
                                  self.trash).items).data,
            "Success retrieved data todo")
Esempio n. 6
0
    def put(self, todo_id):
        """ This method will use to handle update data todo"""

        todo = self.get_by_id(todo_id)
        todo.from_request(request.get_json(force=True))
        todo.save()
        return create_response(200,
                               self.todo_schema.dump(todo).data,
                               msg="Success update data todo")
Esempio n. 7
0
 def get(self, todo_id):
     """ This method is implement GET request to get detail data todo"""
     return create_response(
         200,
         self.todo_schema.dump(self.get_by_id(todo_id)).data,
         "Success get detail todo")