Ejemplo n.º 1
0
    def create_auction(self, item_name):
        item = Item.one(item_name)
        if item is None:
            return {
                "status": "error",
                "errors": ["Item does not exist."],
            }

        def filter_func(auc_record):
            return auc_record.get("status") != const.AUCTION_STATUS_CALLED_FAIL

        if Auction.all(filter_func):
            return {
                "status": "error",
                "errors": ["Auction already exists for this item."],
            }

        auction = Auction(item_name)
        auction.save()

        return {
            "status": "success",
            "auction_id": auction.id,
        }