def retrieve_past_production(request): if request.session.__contains__('account'): args = request.GET if args.__contains__('playerId'): playerId = int(args.__getitem__('playerId')) plantQuery = db.GqlQuery("SELECT __key__ FROM Plant where playerId = :1",playerId) plantKeys= plantQuery.fetch(1000) plantIds = [] for key in plantKeys: plantId = key.id() plantIds.append(plantId) shoeQuery = db.GqlQuery("SELECT * FROM Shoe WHERE plantId in :1",plantIds) shoes = shoeQuery.fetch(1000) shoeIds = [] for shoe in shoes: shoeIds.append(shoe.key().id()) supTrxnQuery = SupplyTransaction.gql("WHERE shoeId in :1 ORDER BY trxnDate DESC",shoeIds) supTrxns = supTrxnQuery.fetch(10) d = [] for st in supTrxns: shoe = Shoe.get_by_id(st.shoeId) dd = st.__dict__['_entity'] dd['trxnDate'] = str(dd['trxnDate']) dd['costPerUnit'] = "%.2f" % dd['costPerUnit'] dd['plantId'] = shoe.plantId dd['sole'] = shoe.sole dd['body'] = shoe.body dd['color'] = shoe.color dd['sellprice'] = "%.2f" % shoe.price d.append(dd) return HttpResponse(simplejson.dumps(d),mimetype="application/json") #return HttpResponse(simplejson.dumps(shoeList),mimetype="application/json") else: return HttpResponse("no player id.") else: return redirect("/")