def GetContext(self): tContext = {} tPaList = [] tOffset = 0 tStringOffset = self.request.get('offset') if (len(tStringOffset) > 0): tOffset = int(tStringOffset) else: tOffset = 0 if (tOffset == 0): tPrev = tOffset else: tPrev = tOffset - 20 tOffset = tOffset + 20 tNext = tOffset tOffset = str(tOffset) tNext = str(tNext) tPrev = str(tPrev) tContext['next'] = str(tNext) tContext['prev'] = str(tPrev) tPa = PaOrder().all() tPa.order('-paDate') tPaList = tPa.fetch(limit=20, offset = int(tOffset)) tContext['palist'] = tPaList return tContext
def ProcessPlayerAuctions(self, pArgumentDic): tPaOrder = PaOrder() if "mc_gross" in pArgumentDic.keys(): tPaOrder.paAmount = pArgumentDic["mc_gross"] if "payer_id" in pArgumentDic.keys(): tPaOrder.paTransactionId = pArgumentDic["payer_id"] tPaOrder.put()
def post(self): tOrderKey = self.request.get('orderid') #logging.debug("tOrderKey: " + tOrderKey) tPaOrder = PaOrder() tPaOrder = PaOrder.get(tOrderKey) tUser = users.get_current_user() tAgent = Agent().GetAgentByEmail(str(tUser.email())) if (tPaOrder.paOrderDeliver == False and tPaOrder.paOrderLock == False and tAgent.agentIsEnabled == True): tGoldAmount = tPaOrder.paAmountInt tGoldAmountLong = tGoldAmount tGoldAmount = tGoldAmount / 1000000 if (tAgent.agentGoldSupply == None): tAgent.agentGoldSupply = 0 tCommission = tGoldAmount * 0.05 + 0.50 tAgent.agentGoldSupply = int( tAgent.agentGoldSupply) - int(tGoldAmountLong) tAgent.agentCurrentCommission = tAgent.agentCurrentCommission + tCommission tAgent.agentTotalCommission = tAgent.agentTotalCommission + tCommission tAgentOrders = tAgent.agentOrders #Add order to agent pa orders tAgentOrders.append(tOrderKey) tAgent.agentOrders = tAgentOrders tAgent.agentCurrentOrderTotal = tAgent.agentCurrentOrderTotal + 1 tAgentKey = tAgent.put() tPaOrder.paDeliveryAgent = str(tAgent.agentId) tPaOrder.paDeliveryAgentNick = tAgent.agentNickName tPaOrder.paOrderDeliver = True tPaOrder.paOrderLock = True tKey = tPaOrder.put() #logging.debug("Delivery by Agent: " + str(tAgentKey)) #logging.debug("Delivery of Order: " + str(tKey)) self.response.headers[ 'Cache-Control'] = 'Cache-Control: no-cache, must-revalidate' self.response.headers['Content-Type'] = 'Content-Type: plain/text' self.response.out.write("Order Delivered") else: #logging.debug('Attempted to Deliver ' + tOrderKey + " by Agent " + tAgent.agentId) self.response.headers[ 'Cache-Control'] = 'Cache-Control: no-cache, must-revalidate' self.response.headers['Content-Type'] = 'Content-Type: plain/text' self.response.out.write("Order Not Deliverable")
def post(self): tOrderKey = self.request.get('orderid') #logging.debug("tOrderKey: " + tOrderKey) tPaOrder = PaOrder() tPaOrder = PaOrder.get(tOrderKey) tUser = users.get_current_user() tAgent = Agent().GetAgentByEmail(str(tUser.email())) if (tPaOrder.paOrderDeliver == False and tPaOrder.paOrderLock == False and tAgent.agentIsEnabled == True): tGoldAmount = tPaOrder.paAmountInt tGoldAmountLong = tGoldAmount tGoldAmount = tGoldAmount / 1000000 if (tAgent.agentGoldSupply == None): tAgent.agentGoldSupply = 0 tCommission = tGoldAmount * 0.05 + 0.50 tAgent.agentGoldSupply = int(tAgent.agentGoldSupply) - int(tGoldAmountLong) tAgent.agentCurrentCommission = tAgent.agentCurrentCommission + tCommission tAgent.agentTotalCommission = tAgent.agentTotalCommission + tCommission tAgentOrders = tAgent.agentOrders #Add order to agent pa orders tAgentOrders.append(tOrderKey) tAgent.agentOrders = tAgentOrders tAgent.agentCurrentOrderTotal = tAgent.agentCurrentOrderTotal + 1 tAgentKey = tAgent.put() tPaOrder.paDeliveryAgent = str(tAgent.agentId) tPaOrder.paDeliveryAgentNick = tAgent.agentNickName tPaOrder.paOrderDeliver = True tPaOrder.paOrderLock = True tKey = tPaOrder.put() #logging.debug("Delivery by Agent: " + str(tAgentKey)) #logging.debug("Delivery of Order: " + str(tKey)) self.response.headers['Cache-Control'] = 'Cache-Control: no-cache, must-revalidate' self.response.headers['Content-Type'] = 'Content-Type: plain/text' self.response.out.write("Order Delivered") else: #logging.debug('Attempted to Deliver ' + tOrderKey + " by Agent " + tAgent.agentId) self.response.headers['Cache-Control'] = 'Cache-Control: no-cache, must-revalidate' self.response.headers['Content-Type'] = 'Content-Type: plain/text' self.response.out.write("Order Not Deliverable")
def ProcessPlayerAuctions(self, pArgumentDic): tPaOrder = PaOrder() if ('mc_gross' in pArgumentDic.keys()): tPaOrder.paAmount = pArgumentDic['mc_gross'] if ('payer_id' in pArgumentDic.keys()): tPaOrder.paTransactionId = pArgumentDic['payer_id'] tPaOrder.put()
def GetContext(self): tContext = {} tVipList = [] tPaKey = urllib.unquote(self.request.get('key')) if (tPaKey != None and len(tPaKey) > 0): tPaOrder = PaOrder.get(tPaKey) if (tPaOrder.paOrderDeliver == None): tPaOrder.paOrderDeliver = False if (tPaOrder.paOrderLock == None): tPaOrder.paOrderLock = False tContext['tPaOrder'] = tPaOrder return tContext
def GetContext(self): tContext = {} tVipList = [] tPaKey = urllib.unquote(self.request.get('key')) if(tPaKey != None and len(tPaKey) > 0): tPaOrder = PaOrder.get(tPaKey) if(tPaOrder.paOrderDeliver == None): tPaOrder.paOrderDeliver = False if(tPaOrder.paOrderLock == None): tPaOrder.paOrderLock = False tContext['tPaOrder'] = tPaOrder return tContext
def receive(self, mail_message): #logging.debug("Received a message from: " + PaOrderHandler.unwraptext(mail_message.sender)) #logging.debug("Subject: " + PaOrderHandler.unwraptext(mail_message.subject)) for bodies in mail_message.bodies('text/plain'): emailtext = "" for body in bodies: try: encodedtext = body[1] emailtext = PaOrderHandler.unwraptext(encodedtext) except: emailtext = body.payload.decode(body.encoding) if(isinstance(emailtext, unicode)): emailtext = emailtext.encode('utf-8') #logging.debug("Body PlainText: " + emailtext) OrderAmountText = self.reOrder.search(emailtext).groupdict()['order'].strip() OrderAmountInt = NumberToGp.ConvertBetToInt(OrderAmountText) OrderId = self.reOrderId.search(emailtext).groupdict()['orderid'].strip() tMatchingOrderQuery = PaOrder.all() tMatchingOrderQuery.filter("paTransactionId", OrderId) tMatches = tMatchingOrderQuery.fetch(10) if(len(tMatches) > 0): return tPaOrder = PaOrder() tPaOrder.paAmount = OrderAmountText tPaOrder.paAmountInt = OrderAmountInt tPaOrder.paTransactionId = OrderId tAssignedAgentClass = DeliveryAssignment() tAssignedAgent = tAssignedAgentClass.GetAssignedAgent() if(tAssignedAgent != 'No Agent Online'): tPaOrder.paAssignedAgent = tAssignedAgent.agentId tPaOrder.paAssignedAgentNick = tAssignedAgent.agentNickName else: tPaOrder.paAssignedAgent = "No Agent Online" tPaOrder.paAssignedAgentNick = "No Agent Online" tPaOrder.put()
def GetContext(self): tContext = {} tAgent = Agent() tAgentHandler = AgentHandler() tOrders = [] tOrder = Order() tUser = self.USER tAgentQuery = Agent().all() tAgentQuery.filter('agentOnline', True) tAgents = tAgentQuery.fetch(100) if (len(tAgents) > 0): tContext['agentnum'] = len(tAgents) tContext['agents'] = tAgents try: tAgent = Agent().GetAgentByEmail(str(tUser.email())) except: pass if (tAgent.agentId == 'No Agent'): tAgent.agentCurrentCommission = 0.0 tAgent.agentTotalCommission = 0.0 tAgent.agentOrders = [] tAgent.agentId = str(tUser.email()) tAgent.agentGoldSupply = 0 tAgent.agentOnline = False tAgent.put() if (tAgent.agentGoldSupply == None): tAgent.agentGoldSupply = 0 tOrderQuery = PaOrder.all() tOrderQuery.filter("paDeliveryAgent", tAgent.agentId) tOrderQuery.order("-paDateDelivered") tOrdersRaw = tOrderQuery.fetch(50) tAgentDonorsQuery = DonorRecord.all() tAgentDonorsQuery.filter('donorAgent', tAgent.agentId) tAgentDonorsQuery.order('-donorDate') tAgentDonations = tAgentDonorsQuery.fetch(20) for o in tOrdersRaw: tOrder = o if (tOrder != None): tOrders.append(tOrder) #tGoldSupply = tAgent.agentGoldSupply logging.debug('Original eoc ' + str(tAgent.agentGoldSupplyEoc)) logging.debug('Original 07 ' + str(tAgent.agentGoldSupply07)) tEocString = NumberToGp.ConvertIntToBet(tAgent.agentGoldSupplyEoc) t07String = NumberToGp.ConvertIntToBet(tAgent.agentGoldSupply07) logging.debug('Stringed version eoc ' + tEocString) logging.debug('Stringed version 07 ' + t07String) #tAgent.__setattr__('agentGoldSupplyEocString', tEocString) #tAgent.__setattr__('agentGoldSupply07String', t07String) tContext['agent'] = tAgent tContext['gpeocstring'] = str(tEocString) tContext['gp07string'] = str(t07String) #tContext['agentgold'] = locale.format("%d", int(tGoldSupply), grouping = True) tContext['orders'] = tOrders tContext['agentcomm'] = locale.format("%0.2f", tAgent.agentCurrentCommission, grouping=True) tContext['agenttotal'] = locale.format("%0.2f", tAgent.agentTotalCommission, grouping=True) tContext['donations'] = tAgentDonations return tContext
def receive(self, mail_message): #logging.debug("Received a message from: " + PaOrderHandler.unwraptext(mail_message.sender)) #logging.debug("Subject: " + PaOrderHandler.unwraptext(mail_message.subject)) for bodies in mail_message.bodies('text/plain'): emailtext = "" for body in bodies: try: encodedtext = body[1] emailtext = PaOrderHandler.unwraptext(encodedtext) except: emailtext = body.payload.decode(body.encoding) if (isinstance(emailtext, unicode)): emailtext = emailtext.encode('utf-8') #logging.debug("Body PlainText: " + emailtext) OrderAmountText = self.reOrder.search( emailtext).groupdict()['order'].strip() OrderAmountInt = NumberToGp.ConvertBetToInt(OrderAmountText) OrderId = self.reOrderId.search( emailtext).groupdict()['orderid'].strip() tMatchingOrderQuery = PaOrder.all() tMatchingOrderQuery.filter("paTransactionId", OrderId) tMatches = tMatchingOrderQuery.fetch(10) if (len(tMatches) > 0): return tPaOrder = PaOrder() tPaOrder.paAmount = OrderAmountText tPaOrder.paAmountInt = OrderAmountInt tPaOrder.paTransactionId = OrderId tAssignedAgentClass = DeliveryAssignment() tAssignedAgent = tAssignedAgentClass.GetAssignedAgent() if (tAssignedAgent != 'No Agent Online'): tPaOrder.paAssignedAgent = tAssignedAgent.agentId tPaOrder.paAssignedAgentNick = tAssignedAgent.agentNickName else: tPaOrder.paAssignedAgent = "No Agent Online" tPaOrder.paAssignedAgentNick = "No Agent Online" tPaOrder.put()