def put(self, category_id): data = Category.parser.parse_args() category = CategoryModel.find_by_uuid(category_id) if category: category.name = data['name'] category.save_entity() #try: # category.name = data['name'] # category.save_to_db() #except: #return {"message":"An error occurred updating the category."},500 return category.json()
def delete(self, category_id): category = CategoryModel.find_by_uuid(category_id) if category: category.delete_from_db() return {'message': 'category deleted'}
def get(self, category_id): category = CategoryModel.find_by_uuid(category_id) if category: return category.json() return {'message': 'category not found'}, 404