@ -94,9 +88,7 @@ class BuyableItemHandler(BaseHandler):
ifamount<1:
ifamount<1:
returnrc.BAD_REQUEST
returnrc.BAD_REQUEST
ifamount>30:
ifamount>30:
ret=rc.BAD_REQUEST
returngetError(rc.BAD_REQUEST,"You are trying to buy more than 30 items at once. This is not permitted. If you think it should, mail the admins / fix this in the handlers.py")
ret.write("\nYou are trying to buy more than 30 items at once. This is not permitted. If you think it should, mail the admins / fix this in the handlers.py\n");
returngetError(rc.BAD_REQUEST,"You need to specify either items or deposits (or both).")
ret.write("\nYou need to specify either items or deposits (or both).\n")
returnret
ifnotrequest.data.has_key("items"):
ifnotrequest.data.has_key("items"):
request.data['items']=[]
request.data['items']=[]
@ -149,20 +137,13 @@ class BuyableItemHandler(BaseHandler):
raiseTypeError()
raiseTypeError()
itemList+=request.data['deposits']
itemList+=request.data['deposits']
exceptTypeError:
exceptTypeError:
ret=rc.BAD_REQUEST
returngetError(rc.BAD_REQUEST,"The items/deposists parameter have to be a list.")
ret.write("\nThe items/deposists parameter have to be a list.\n")
returnret
iflen(itemList)>30:
iflen(itemList)>30:
ret=rc.BAD_REQUEST
returngetError(rc.BAD_REQUEST,"You are trying to buy more than 30 items at once. This is not permitted. If you think it should, mail the admins / fix this in the handlers.py")
ret.write("\nYou are trying to buy more than 30 items at once. This is not permitted. If you think it should, mail the admins / fix this in the handlers.py\n");
returnret
iflen(itemList)==0:
iflen(itemList)==0:
ret=rc.BAD_REQUEST
returngetError(rc.BAD_REQUEST,"Your request contains no items/deposits.")
ret.write("\nYour request contains no items/deposits.\n")
returnret
ids={}
ids={}
foriteminitemList:
foriteminitemList:
@ -174,13 +155,9 @@ class BuyableItemHandler(BaseHandler):
ret.write("\nThe item with the id '%s' could not be found\n"%(item,))
ret.write("\nThe item with the id '%s' could not be found\n"%(item,))
returnret
returnret
exceptValueError:
exceptValueError:
ret=rc.NOT_FOUND
returngetError(rc.NOT_FOUND,"Item ids should be numeric (and preferably integers)")
ret.write("\nItem ids should be numeric (and preferably integers)\n")
returngetError(rc.BAD_REQUEST,"A negative amount (or zeroed) is not supported right now (there has not been put enough thought into the 'lending money' process")
ret.write("\nA negative amount (or zeroed) is not supported right now (there has not been put enough thought into the 'lending money' process\n")
returnret
tType=None
tType=None
try:
try:
tType=TransactionType.objects.get(id=tTypeId)
tType=TransactionType.objects.get(id=tTypeId)
exceptTransactionType.DoesNotExist:
exceptTransactionType.DoesNotExist:
ret=rc.BAD_REQUEST
returngetError(rc.BAD_REQUEST,"Your TransactionType could not be found")
ret.write("\nYour TransactionType could not be found\n")
returnret
trans=Transaction()
trans=Transaction()
trans.user=request.user
trans.user=request.user
trans.transactionType=tType
trans.transactionType=tType
@ -326,24 +303,18 @@ class TransactionVirtualHandler(BaseHandler):