コード例 #1
0
 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
コード例 #2
0
 def post(self):
     tAgentQuery = Agent().all()
     tAgentList = tAgentQuery.fetch(100)
     agent = Agent()
     
     for agent in tAgentList:
         agent.agentOnline = False
         agent.put()
     
     self.response.out.write("Success")
コード例 #3
0
    def get(self):
        tAgent = Agent()
        tAgentsOnline = []
        
        tCurrentTime = datetime.datetime.now()
        tIncrement = datetime.timedelta(minutes = -30)
        tTime = tIncrement + tCurrentTime
        
        tAgentQuery = Agent().all()
        tAgentQuery.filter("agentOnline", True)
        tAgentQuery.filter("agentLastActive <", tTime)
        
        tAgentsOnline = tAgentQuery.fetch(10)

        if (len(tAgentsOnline) > 0):
            for tAgent in tAgentsOnline:
                tAgent.agentOnline = False
                tAgent.put()
コード例 #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