def get(cls, agenda_id: str = None): if not agenda_id: list = AgendaModel.fetch_all() return agendaListSchema.dump(list), 200 agenda = AgendaModel.find_by_id(agenda_id) if not agenda: return { "message": "Agenda <id={}> not found.".format(agenda_id) }, 404 return agendaSchema.dump(agenda), 200
def post(cls): task_json = request.get_json() task = task_schema.load(task_json) if not AgendaModel.find_by_id(task.agenda_id): return {"message": "The specified agenda <id={task.agenda_id}}> was not found."}, 400 task.save() return task_schema.dump(task), 201