Example #1
0
    def get(self):
        Guser = users.get_current_user()
        if Guser:
            findRequest = MyAffiliates.query(MyAffiliates.strReference == Guser.user_id())
            thisMyAffiliatesList = findRequest.fetch()

            if len(thisMyAffiliatesList) > 0:
                thisMyAffiliates = thisMyAffiliatesList[0]
            else:
                thisMyAffiliates = MyAffiliates()
                thisMyAffiliates.writeReference(strinput=Guser.user_id())
                thisMyAffiliates.put()

            if thisMyAffiliates.strAvailable >= 50:
                findRequest = Profile.query(Profile.strReference == Guser.user_id())
                thisProfileList = findRequest.fetch()
                if len(thisProfileList) > 0:
                    thisProfile = thisProfileList[0]
                else:
                    thisProfile = Profile()
                    thisProfile.writeReference(strinput=Guser.user_id())
                    thisProfile.put()
                try:
                    thisProfile.strWallet = thisProfile.strWallet + thisMyAffiliates.strAvailable
                    thisMyAffiliates.strAvailable = 0
                    thisProfile.strTotalFundsReceived = thisProfile.strTotalFundsReceived + thisMyAffiliates.strAvailable
                    thisMyAffiliates.put()
                    thisProfile.put()
                    self.response.write("Succesfully Transferred all Affiliate Income into your Wallet")
                except:
                    self.response.write("Error Transferring your Affiliate funds into your Wallet")
            else:
                self.response.write("Error Transferring your Affiliate funds into your Wallet insufficient credit")
Example #2
0
    def get(self):
        Guser = users.get_current_user()
        if Guser:
            vstrSendFunding = self.request.get('vstrSendFunding')
            vstrCampaignID = self.request.get('vstrCampaignID')

            findRequest = Campaigns.query(
                Campaigns.strCampaignID == vstrCampaignID)
            thisCampaignList = findRequest.fetch()

            self.response.write("Send fund running...")

            if len(thisCampaignList) > 0:
                thisCampaign = thisCampaignList[0]
            else:
                thisCampaign = Campaigns()

            findRequest = Profile.query(
                Profile.strReference == Guser.user_id())
            thisProfileList = findRequest.fetch()

            if len(thisProfileList) > 0:
                thisProfile = thisProfileList[0]
            else:
                thisProfile = Profile()

            if thisProfile.strWallet > int(vstrSendFunding):
                thisProfile.strWallet = thisProfile.strWallet - int(
                    vstrSendFunding)
                thisProfile.strTotalFundsSent = thisProfile.strTotalFundsSent + int(
                    vstrSendFunding)
                thisProfile.put()
                thisCampaign.AddToReceivedFunds(strinput=vstrSendFunding)
                thisCampaign.put()

                try:
                    findRequest = Profile.query(
                        Profile.strReference == thisCampaign.strReference)
                    thisReceiveProfileList = findRequest.fetch()

                    if len(thisReceiveProfileList) > 0:
                        thisReceiveProfile = thisReceiveProfileList[0]
                    else:
                        thisReceiveProfile = Profile()

                    thisReceiveProfile.strTotalFundsReceived = thisReceiveProfile.strTotalFundsReceived + int(
                        vstrSendFunding)
                    thisReceiveProfile.put()

                    self.response.write("Succesfully Funded Campaign")
                except:
                    self.response.write("Error Funding Project")
            else:
                self.response.write(
                    "Error Funding Campaign Insufficient Funds")