Fixed bug in bulkBuy when not buying deposit
This commit is contained in:
parent
16a0686b03
commit
939159a1c9
|
@ -133,13 +133,16 @@ class BuyableItemHandler(BaseHandler):
|
||||||
ret.write("\nYou need to specify either items or deposits (or both).\n")
|
ret.write("\nYou need to specify either items or deposits (or both).\n")
|
||||||
return ret
|
return ret
|
||||||
|
|
||||||
|
if not request.data.has_key("items"):
|
||||||
|
request.data['items'] = []
|
||||||
|
if not request.data.has_key("deposits"):
|
||||||
|
request.data['deposits'] = []
|
||||||
|
|
||||||
itemList = []
|
itemList = []
|
||||||
try:
|
try:
|
||||||
if request.data.has_key('items'):
|
|
||||||
if not isinstance(request.data['items'], Iterable):
|
if not isinstance(request.data['items'], Iterable):
|
||||||
raise TypeError()
|
raise TypeError()
|
||||||
itemList += request.data['items']
|
itemList += request.data['items']
|
||||||
if request.data.has_key('deposits'):
|
|
||||||
if request.data.has_key('items'):
|
if request.data.has_key('items'):
|
||||||
if not isinstance(request.data['deposits'], Iterable):
|
if not isinstance(request.data['deposits'], Iterable):
|
||||||
raise TypeError()
|
raise TypeError()
|
||||||
|
@ -182,11 +185,11 @@ class BuyableItemHandler(BaseHandler):
|
||||||
order.create(request.user)
|
order.create(request.user)
|
||||||
order.save()
|
order.save()
|
||||||
purchases = []
|
purchases = []
|
||||||
if request.data.has_key('items'):
|
# buy items
|
||||||
for item in request.data['items']:
|
for item in request.data['items']:
|
||||||
p = Purchase.create(order, ids[item], isDeposit=False)
|
p = Purchase.create(order, ids[item], isDeposit=False)
|
||||||
p.save()
|
p.save()
|
||||||
if request.data.has_key('deposits'):
|
# buy deposits
|
||||||
for item in request.data['deposits']:
|
for item in request.data['deposits']:
|
||||||
p = Purchase.create(order, ids[item], isDeposit=True)
|
p = Purchase.create(order, ids[item], isDeposit=True)
|
||||||
p.save()
|
p.save()
|
||||||
|
|
Loading…
Reference in New Issue