def get(cls): name = request.get_json()["name"] list = ListModel.find_by_name(name) if list: return list_schema.dump(list), 200 return {"message": LIST_NOT_FOUND}, 404
def delete(cls): name = request.get_json()["name"] list = ListModel.find_by_name(name) if list: list.delete_from_db() return {"message": LIST_DELETED}, 200 return {"message": LIST_NOT_FOUND}, 404
def post(cls): name = request.get_json()["name"] if ListModel.find_by_name(name): return {"message": NAME_ALREADY_EXISTS.format(name=name)}, 400 list = ListModel(name=name) try: list.save_to_db() except: return {"message": ERROR_INSERTING}, 500 return list_schema.dump(list), 201