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 GetAssignedAgent(self, pOrder=None): tAgent = Agent() tPaypal = PaypalOrder() tAgents = [] Switch = {} tOrder = Order() tOrder = pOrder #Need to implement these methods #Switch[(1,2)] = tPaypal.UseFullAndBackupAgents #Switch[(0,2)] = tPaypal.UseBackupAgent #Switch[(2,2)] = tPaypal.UseFullAgent Switch[(0, 0)] = tPaypal.AssignNoAgent Switch[(0, 1)] = tPaypal.UseBackupAgent Switch[(1, 0)] = tPaypal.UseFullAgent Switch[(1, 1)] = tPaypal.UseFullAndBackupAgents Switch[(2, 0)] = tPaypal.UseFullAgent Switch[(2, 1)] = tPaypal.UseFullAndBackupAgents Switch[(3, 0)] = tPaypal.UseFullAgent Switch[(3, 1)] = tPaypal.UseFullAgent #Based on the raw online numbers of each group tCurrentState = (tPaypal.GetNumberofOnlineFullAgents(), tPaypal.GetNumberofOnlineBackupAgents()) #logging.debug("Current State" + str(tCurrentState)) #The end agent will be handled in each function tAgent = Switch[tCurrentState]() if (tOrder != None): try: #logging.debug("Agent Current Total: " + str(tAgent.agentCurrentOrderTotal)) #logging.debug("Order Quantity: " + str(tOrder.orderQuantity)) tAgent.agentCurrentOrderTotal = tAgent.agentCurrentOrderTotal + int( tOrder.orderQuantity) #logging.debug("New Agent Current Total: " + str(tAgent.agentCurrentOrderTotal)) tAgent.agentNotify = True tAgent.put() #logging.debug("GetAssignedAgent returning agent: " + str(tAgent.agentId)) return tAgent.agentId except: #logging.debug("Hit an error") return "No Agent Online" else: try: return str(tAgent.agentId) except: return "No Agent Online"
def post(self): tUser = users.get_current_user() tAgent = Agent().GetAgentByEmail(tUser.email()) tStatus = tAgent.agentOnline if (tStatus == False): tAgent.agentOnline = True tAgent.agentCurrentOrderTotal = 100 tReturn = "You're Online!" else: tAgent.agentOnline = False tReturn = "You're Offline!" tAgent.put() self.response.out.write(tReturn) exit
def GetAssignedAgent(self, pOrder = None): tAgent = Agent() tAssignment = DeliveryAssignment() tAgents = [] Switch = {} tOrder = PaOrder() tOrder = pOrder #Need to implement these methods #Switch[(1,2)] = tPaypal.UseFullAndBackupAgents #Switch[(0,2)] = tPaypal.UseBackupAgent #Switch[(2,2)] = tPaypal.UseFullAgent Switch[(0,0)] = tAssignment.AssignNoAgent Switch[(0,1)] = tAssignment.UseBackupAgent Switch[(1,0)] = tAssignment.UseFullAgent Switch[(1,1)] = tAssignment.UseFullAndBackupAgents Switch[(2,0)] = tAssignment.UseFullAgent Switch[(2,1)] = tAssignment.UseFullAndBackupAgents Switch[(3,0)] = tAssignment.UseFullAgent Switch[(3,1)] = tAssignment.UseFullAgent #Based on the raw online numbers of each group tCurrentState = (tAssignment.GetNumberofOnlineFullAgents(), tAssignment.GetNumberofOnlineBackupAgents()) #logging.debug("Current State" + str(tCurrentState)) #The end agent will be handled in each function tAgent = Switch[tCurrentState]() if (tOrder != None): try: #logging.debug("Agent Current Total: " + str(tAgent.agentCurrentOrderTotal)) #logging.debug("Order Quantity: " + str(tOrder.paAmountInt)) tAgent.agentCurrentOrderTotal = tAgent.agentCurrentOrderTotal + 1 #logging.debug("New Agent Current Total: " + str(tAgent.agentCurrentOrderTotal)) tAgent.agentNotify = True tAgent.put() #logging.debug("GetAssignedAgent returning agent: " + str(tAgent.agentId)) return tAgent except: #logging.debug("Hit an error") return "No Agent Online" else: try: return tAgent except: return "No Agent Online"