コード例 #1
0
def make_coffee(row):
	'''makes a coffee object from the db row'''

	OnePoundPrices = {'$12.95': 8.75, '$13.95': 9.75, '$14.95': 9.50, '$14.45': 9.50}
	TwoPoundPrices = {'$24.15': 8.50*2, '$24.95': 8.50*2, '$24.75': 8.50*2, '$28.20': 8.50*2, '$25.70': 8.50*2, '$26.70': 8.50*2}
	FivePoundPrices = {'$59.15': 8.25*5, '$59.00': 8.25*5, '$70.50': 9.25*5, '$60.35': 9.25*5, '$63.35': 9.25*5, '$63.65': 9.25*5}

	c = Coffee()
	c.name = row[0]
	c.description = row[1]
	c.one_pound_price = OnePoundPrices[row[2]]
	c.two_pound_price = TwoPoundPrices[row[3]]
	c.five_pound_price = FivePoundPrices[row[4]]
	c.prices = {1: c.one_pound_price, 2: c.two_pound_price, 5: c.five_pound_price }
	c.image_data = row[5]

	return c