Exemplo n.º 1
0
    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")
Exemplo n.º 2
0
 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")    
Exemplo n.º 3
0
 def PostContext(self):
     
     tUser = self.GetUser()
     tDonor = DonorRecord()
     
     tDonatorRsName = self.request.get('name')
     #logging.debug("Quantity Entered: " + str(self.request.get('quantity')))
     tDonatorAmount = int(self.request.get('quantity'))
     tDonatorNote = self.request.get('memo')
     tDonatorForumName = self.request.get('fname')
     tFormEmail = self.request.get('email')
     tAgentGold = self.request.get('agentgold')
     
     tDonor.donorAgent = tUser.email()
     tDonor.donorForumName = tDonatorForumName
     tDonor.donorMemo = tDonatorNote
     tDonor.donorRsName = tDonatorRsName
     tDonor.donorGoldAmount = int(tDonatorAmount)
     tDonor.put()
     
     tAgent = Agent()
     try:
         if (len(tFormEmail) > 0):
             tAgent = Agent().GetAgentByEmail(tFormEmail)
         else: 
             tAgent = Agent().GetAgentByEmail(str(tUser.email()))
     except:
         tAgent = Agent().GetAgentByEmail(str(tUser.email()))
     
     if (tAgent.agentGoldSupply == None):
         tAgent.agentGoldSupply = 0
         
     if (tDonatorAmount < 0):
         #logging.debug(str(tAgentGold))
         tDonatorAmount = tDonatorAmount / 1000000.0
         if (tAgentGold == 'on'):
             tCommission = tDonatorAmount * 0.65 * -1.0
         else:
             tAgent.agentGoldSupply += int(tDonatorAmount * 1000000.0)
             tCommission = tDonatorAmount * 0.05 * -1.0
         #logging.debug("Agent Commission: " + str(tDonatorAmount * -1.0))
         tAgent.agentCurrentCommission += tCommission
         tAgent.agentTotalCommission += tCommission
     else:
         tAgent.agentGoldSupply += tDonatorAmount
         
     tAgent.put()
     
     return {}
     
     
 
 
     
                 
Exemplo n.º 4
0
    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