Fixed bug in bulkBuy when not buying deposit
This commit is contained in:
parent
16a0686b03
commit
939159a1c9
|
@ -132,18 +132,21 @@ class BuyableItemHandler(BaseHandler):
|
|||
ret = rc.BAD_REQUEST
|
||||
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()
|
||||
|
|
Loading…
Reference in New Issue