Exemplo n.º 1
0
    def post(self):
        category_name = api.payload.pop("category")
        category = Category.first(name=category_name)
        if not category:
            api.abort(404, "Category doesn't exist")

        good: Good = Good(category=category, **api.payload)
        return "success" if good.commit() else api.abort(409)
Exemplo n.º 2
0
 def get(self, id: int):
     category: Category = Category.first(id=id)
     return category if category else api.abort(404)