Fixed bug in bulkBuy when not buying deposit

This commit is contained in:
seba 2011-10-18 02:56:29 +02:00
parent 16a0686b03
commit 939159a1c9
1 changed files with 18 additions and 15 deletions

View File

@ -133,17 +133,20 @@ class BuyableItemHandler(BaseHandler):
ret.write("\nYou need to specify either items or deposits (or both).\n")
return ret
if not request.data.has_key("items"):
request.data['items'] = []
if not request.data.has_key("deposits"):
request.data['deposits'] = []
itemList = []
try:
if not isinstance(request.data['items'], Iterable):
raise TypeError()
itemList += request.data['items']
if request.data.has_key('items'):
if not isinstance(request.data['items'], Iterable):
if not isinstance(request.data['deposits'], Iterable):
raise TypeError()
itemList += request.data['items']
if request.data.has_key('deposits'):
if request.data.has_key('items'):
if not isinstance(request.data['deposits'], Iterable):
raise TypeError()
itemList += request.data['deposits']
itemList += request.data['deposits']
except TypeError:
ret = rc.BAD_REQUEST
ret.write("\nThe items/deposists parameter have to be a list.\n")
@ -182,14 +185,14 @@ class BuyableItemHandler(BaseHandler):
order.create(request.user)
order.save()
purchases = []
if request.data.has_key('items'):
for item in request.data['items']:
p = Purchase.create(order, ids[item], isDeposit=False)
p.save()
if request.data.has_key('deposits'):
for item in request.data['deposits']:
p = Purchase.create(order, ids[item], isDeposit=True)
p.save()
# buy items
for item in request.data['items']:
p = Purchase.create(order, ids[item], isDeposit=False)
p.save()
# buy deposits
for item in request.data['deposits']:
p = Purchase.create(order, ids[item], isDeposit=True)
p.save()
order.updatePrice(commit=True)
order.save()