def get(self): Guser = users.get_current_user() if Guser: vstrapply_boost = self.request.get('vstrapply_boost') vstrCampaignID = self.request.get('vstrCampaignID') findRequest = Campaigns.query( Campaigns.strCampaignID == vstrCampaignID) thisCampaignList = findRequest.fetch() if len(thisCampaignList) > 0: thisCampaign = thisCampaignList[0] else: thisCampaign = Campaigns() if (thisCampaign.strBoost + int(vstrapply_boost)) <= 10: findRequest = Profile.query( Profile.strReference == thisCampaign.strReference) thisProfileList = findRequest.fetch() if len(thisProfileList) > 0: thisProfile = thisProfileList[0] else: thisProfile = Profile() if thisProfile.strWallet > int(vstrapply_boost): thisCampaign.setBoostLevel(strinput=vstrapply_boost) thisProfile.strWallet = thisProfile.strWallet - int( vstrapply_boost) thisProfile.put() self.response.write("Boost Level Successfully Adjusted") else: self.response.write( "Boost Level not Adjusted insufficient funds") elif thisCampaign.strBoost < 10: vstrapply_boost = 10 - thisCampaign.strBoost findRequest = Profile.query( Profile.strReference == thisCampaign.strReference) thisProfileList = findRequest.fetch() if len(thisProfileList) > 0: thisProfile = thisProfileList[0] else: thisProfile = Profile() if thisProfile.strWallet > vstrapply_boost: vstrapply_boost = str(vstrapply_boost) thisCampaign.setBoostLevel(strinput=vstrapply_boost) thisProfile.strWallet = thisProfile.strWallet - int( vstrapply_boost) thisProfile.put() self.response.write("Boost Level Successfully Adjusted") else: self.response.write( "Boost Level not Adjusted insufficient funds") else: self.response.write("Campaign fully boosted") thisCampaign.put()
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")
def get(self): Guser = users.get_current_user() if Guser: findRequest = Promotions.query(Promotions.strReference == Guser.user_id()) thisPromotionsList = findRequest.fetch() if len(thisPromotionsList) > 0: thisPromotions = thisPromotionsList[0] else: thisPromotions = Promotions() thisPromotions.writeReference(strinput=Guser.user_id()) thisPromotions.put() 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() if thisProfile.strWallet > thisPromotions.strAutoDownLine: thisProfile.strWallet = thisProfile.strWallet - thisPromotions.strAutoDownLine thisProfile.put() thisPromotions.strEnableAutoDownLine = True thisPromotions.strTotalPromos = thisPromotions.strTotalPromos + thisPromotions.strAutoDownLine thisPromotions.put() self.response.write("Auto Down-Line Enabled") else: self.response.write("Failed to enable Auto Down-Line - Insufficient Funds")
def get(self): Guser = users.get_current_user() if Guser: findRequest = Profile.query( Profile.strReference == Guser.user_id()) thisProfileList = findRequest.fetch() if len(thisProfileList) > 0: thisProfile = thisProfileList[0] else: thisProfile = Profile() findRequest = BankAccount.query( BankAccount.strReference == Guser.user_id()) thisBankAccountList = findRequest.fetch() if len(thisBankAccountList) > 0: thisBankAccount = thisBankAccountList[0] else: thisBankAccount = BankAccount() thisBankAccount.writeReference(strinput=Guser.user_id()) thisBankAccount.put() template = template_env.get_template( "templates/admin/wallet/wallet.html") context = { 'thisProfile': thisProfile, 'thisBankAccount': thisBankAccount } self.response.write(template.render(context))
async def on_reaction_add(self, reaction, user): global gamechannel global valid # game status global winnerPoints global color # Win Validation if reaction.message.channel == gamechannel != None and valid and reaction.message.content == startmsg + react + f' {color}' + '.' and str( reaction ) == emojis[ color] and user != self.user: # checks if the reaction is from a valid minigame session and if it's the right emoji playersinfo = shelve.open('players.info', 'c', writeback=True) # db open # finishing the actual open game await gamechannel.send(winmsg1 + user.name + winmsg2) valid = False # checks if the player profile already exists try: data = playersinfo[f'{user.id}'] del data except: playersinfo[f'{user.id}'] = Profile(user.id) # point computation playersinfo[f'{user.id}'].addPoint(winnerPoints) playersinfo.close() # db close del color
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")
def get(self): Guser = users.get_current_user() if Guser: findRequest = Promotions.query(Promotions.strReference == Guser.user_id()) thisPromotionsList = findRequest.fetch() if len(thisPromotionsList) > 0: thisPromotions = thisPromotionsList[0] else: thisPromotions = Promotions() thisPromotions.writeReference(strinput=Guser.user_id()) thisPromotions.put() 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() if thisProfile.strWallet > thisPromotions.strSocialMediaPromo: thisProfile.strWallet = thisProfile.strWallet - thisPromotions.strSocialMediaPromo thisProfile.put() thisPromotions.strEnableSocialMediaPromo = True thisPromotions.strTotalPromos = thisPromotions.strTotalPromos + thisPromotions.strSocialMediaPromo thisPromotions.put() self.response.write("Social Media Promos Enabled") else: self.response.write("Failure enabling Social Media Promos - Insufficient Funds")
def get(self): Guser = users.get_current_user() if Guser: findRequests = Promotions.query(Promotions.strReference == Guser.user_id()) thisPromotionsList = findRequests.fetch() if len(thisPromotionsList) > 0: thisPromotions = thisPromotionsList[0] else: thisPromotions = Promotions() thisPromotions.writeReference(strinput=Guser.user_id()) thisPromotions.put() findRequests = Profile.query(Profile.strReference == Guser.user_id()) thisProfileList = findRequests.fetch() if len(thisProfileList) > 0: thisProfile = thisProfileList[0] else: thisProfile = Profile() thisProfile.writeReference(strinput=Guser.user_id()) thisProfile.put() if thisProfile.strWallet > thisPromotions.strPriorityListing: thisProfile.strWallet = thisProfile.strWallet - thisPromotions.strPriorityListing thisProfile.put() thisPromotions.strEnablePriorityListing = True thisPromotions.strTotalPromos = thisPromotions.strTotalPromos + thisPromotions.strPriorityListing thisPromotions.put() self.response.write("Priority Listing Enabled") else: self.response.write("Failed to enable Priority Listing- Insufficient funds")
def test_provider_id(self): # Arrange name = "random name" provider_id = "random_provider_id" profile = Profile(name, provider_id, 1) # Act & Assert self.assertEqual(profile.name, name) self.assertEqual(profile.provider_id, provider_id)
def read_input(file): try: with open(file) as f: data = json.load(f) profiles = [Profile(**profile) for profile in data["profiles"]] return profiles except ValueError: sys.exit('Json decode error! Please check file format') except FileNotFoundError: sys.exit('File not found! Please enter correct file path')
def post(self): Guser = users.get_current_user() if Guser: 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()) vstrPayPalEmail = self.request.get('vstrPayPalEmail') infoUpdated = False if not (vstrPayPalEmail == None): thisProfile.writePayPalEmail(strinput=vstrPayPalEmail) thisProfile.put() infoUpdated = True vstrAccountHolder = self.request.get('vstrAccountHolder') vstrBankName = self.request.get('vstrBankName') vstrBranchCode = self.request.get('vstrBranchCode') vstrAccountNumber = self.request.get('vstrAccountNumber') vstrAccountType = self.request.get('vstrAccountType') if ((not (vstrAccountHolder == None)) and (not (vstrAccountNumber == None))): findRequest = BankAccount.query( BankAccount.strReference == Guser.user_id()) thisBankAccountList = findRequest.fetch() if len(thisBankAccountList) > 0: thisBankAccount = thisBankAccountList[0] else: thisBankAccount = BankAccount() thisBankAccount.writeReference(strinput=Guser.user_id()) thisBankAccount.writeAccountHolder(strinput=vstrAccountHolder) thisBankAccount.writeBankName(strinput=vstrBankName) thisBankAccount.writeBranchCode(strinput=vstrBranchCode) thisBankAccount.writeAccountType(strinput=vstrAccountType) thisBankAccount.put() infoUpdated = True if infoUpdated: self.response.write( "Account Linking Information is successfully updated") else: self.response.write( "Account Linking Information not updated we will not be able to process your withdrawals successfully" )
def load_default_profile(): global decoders default_profile = Profile(default_profile_name, profiles_dirs) if default_profile.rhasspy.get('preload_profile', False): try: # Load speech to text decoder decoder = maybe_load_decoder(default_profile) decoders[default_profile.name] = decoder except Exception as e: logging.error('Failed to pre-load profile') if default_profile.rhasspy.get('listen_on_start', False): # Start listening for wake word listen_for_wake(default_profile)
def get(self): Guser = users.get_current_user() if Guser: vstrWithDrawalAmount = self.request.get('vstrWithDrawalAmount') vstrWithdrawalMethod = self.request.get('vstrWithdrawalMethod') vstrWithDrawalAmount = int(vstrWithDrawalAmount) 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()) if (thisProfile.strWallet > vstrWithDrawalAmount) and (vstrWithDrawalAmount > 100): thisProfile.strWallet = thisProfile.strWallet - vstrWithDrawalAmount thisProfile.strWithdraw = thisProfile.strWithdraw + vstrWithDrawalAmount Today = datetime.datetime.now() Today = Today.date() thisMonth = Today.month thisYear = Today.year if thisMonth < 12: thisMonth = thisMonth + 1 else: thisMonth = 1 thisYear = thisYear + 1 thisDay = Today.day Today = datetime.date(year=thisYear, month=thisMonth, day=thisDay) thisProfile.strScheduleWithdrawal = Today thisProfile.strWithDrawMethod = vstrWithdrawalMethod thisProfile.put() self.response.write("Withdrawal Successfully scheduled") else: self.response.write( "Cannot Schedule a withdrawal either because your withdrawal is less than $ 100.00 or your Balance is less than $ 100.00" )
def main(): profile1 = Profile("joe", "M", "F", 72, list(range(50, 90)), 5, 20, list(range(18, 50)), 5, "Jewish", 5, "D", 5, "I", "E", 5, "N", "Y", 5, "M", "M", 5, "C", 5) profile2 = Profile("Jane", "F", "M", 68, list(range(40, 100)), 5, 19, list(range(18, 24)), 5, "Buddhist", 5, "I", 9, "E", "E", 5, "Y", "Y", 5, "N", "N", 5, "D", 5) profile3 = Profile("Mary", "F", "M", 62, list(range(73, 77)), 2, 18, list(range(18, 21)), 5, "Christian", 1, "R", 10, "E", "E", 7, "N", "N", 5, "N", "M", 2, "D", 4) profile4 = Profile("Jackie", "F", "M", 65, list(range(67, 80)), 5, 42, list(range(18, 30)), 5, "Muslim", 5, "R", 5, "I", "I", 5, "N", "N", 5, "N", "N", 5, "C", 5) profileList = [profile2, profile1, profile4, profile3] print(profile1.find_opposite(profileList)) print() print(profile1.find_hated(profileList)) print() print(profile1.find_friend_zone(profileList))
def post(self): Guser = users.get_current_user() if Guser: vstrCampaignID = self.request.get('vstrCampaignID') findRequest = Campaigns.query( Campaigns.strCampaignID == vstrCampaignID) thisCampaignList = findRequest.fetch() if len(thisCampaignList) > 0: thisCampaign = thisCampaignList[0] else: thisCampaign = Campaigns() if not (thisCampaign.strPromoted): findRequest = Constant.query( Constant.strReference == Guser.user_id()) thisConstantList = findRequest.fetch() if len(thisConstantList) > 0: thisConstant = thisConstantList[0] else: thisConstant = Constant() thisConstant.writeReference(strinput=Guser.user_id()) thisConstant.put() 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()) if (thisProfile.strWallet > thisConstant.strPromotionCost): thisProfile.strWallet = thisProfile.strWallet - thisConstant.strPromotionCost thisCampaign.strPromoted = True thisProfile.put() thisCampaign.put() self.response.write("Campaign Successfully Promoted") else: self.response.write( "Campaign cannot be promoted insufficient funds") else: self.response.write("Campaign Already Promoted")
def get(self): Guser = users.get_current_user() template = template_env.get_template('templates/register.html') if Guser: findRequest = Profile.query( Profile.strReference == Guser.user_id()) thisProfileList = findRequest.fetch() if len(thisProfileList) > 0: thisProfile = thisProfileList[0] else: thisProfile = Profile() if thisProfile.strProfileActivated: context = {'ProfileIsActive': "ProfileIsActive"} else: context = {} self.response.write(template.render(context)) else: context = {} self.response.write(template.render(context))
def get(self): Guser = users.get_current_user() if Guser: vstrFirstName = self.request.get('vstrFirstName') vstrSurname = self.request.get('vstrSurname') vstrCellNumber = self.request.get('vstrCellNumber') vstrEmail = self.request.get('vstrEmail') findRequest = Profile.query( Profile.strReference == Guser.user_id()) thisProfileList = findRequest.fetch() if len(thisProfileList) > 0: thisProfile = thisProfileList[0] else: thisProfile = Profile() try: thisProfile.writeReference(strinput=Guser.user_id()) thisProfile.writeFullNames(strinput=vstrFirstName) thisProfile.writeSurname(strinput=vstrSurname) thisProfile.writeCell(strinput=vstrCellNumber) thisProfile.writeEmail(strinput=vstrEmail) thisProfile.CreateConfirmCode() if thisProfile.sendActivationCode() == True: thisProfile.put() self.response.write( "A Comfirmation Email has been sent please follow the instructions on the email to fully activate your account" ) else: self.response.write( "Send Mail Function causing a general Error please check your email address" ) except: self.response.write( "There was an error sending a confirmation email please try again" )
def post(self): Guser = users.get_current_user() if Guser: vstrCampaignType = self.request.get('vstrCampaignType') vstrCampaignName = self.request.get('vstrCampaignName') vstrCampaignIntro = self.request.get('vstrCampaignIntro') vstrCampaignBody = self.request.get('vstrCampaignBody') vstrFundMe = self.request.get('vstrFundMe') findRequest = Constant.query( Constant.strReference == Guser.user_id()) thisConstantList = findRequest.fetch() if len(thisConstantList) > 0: thisConstant = thisConstantList[0] else: thisConstant = Constant() findRequest = Campaigns.query( Campaigns.strReference == Guser.user_id()) thisCampaignsList = findRequest.fetch() findRequest = Profile.query( Profile.strReference == Guser.user_id()) thisProfileList = findRequest.fetch() if len(thisProfileList) > 0: thisProfile = thisProfileList[0] else: thisProfile = Profile() if (thisProfile.strWallet > thisConstant.strCampaignCost) or ( len(thisCampaignsList) < thisConstant.strFreeCampaignAllowance): if len(thisCampaignsList ) > thisConstant.strFreeCampaignAllowance: thisProfile.strWallet = thisProfile.strWallet - thisConstant.strCampaignCost else: pass try: thisCampaign = Campaigns() thisCampaign.writeReference(strinput=Guser.user_id()) thisCampaignID = str(Guser.user_id()) + str( len(thisCampaignsList)) thisCampaign.writeCampaignID(strinput=thisCampaignID) thisPublicURL = "/campaigns/public/" + thisCampaignID thisPublicURL = thisConstant.strAppURL + thisPublicURL thisCampaign.writeCampaignURL(strinput=thisPublicURL) thisCampaign.writeCampaignName(strinput=vstrCampaignName) if vstrCampaignType == "Personal": thisCampaign.setBusinessCampaign(strinput=True) else: thisCampaign.setBusinessCampaign(strinput=False) thisCampaign.writeCampaignIntro(strinput=vstrCampaignIntro) thisCampaign.writeCampaignBody(strinput=vstrCampaignBody) thisCampaign.writeFundMe(strinput=vstrFundMe) # thisCampaign.setActive() Cannot set the campaign to active since this is a draft StartDate = datetime.datetime.now() StartDate = StartDate.date() EndDate = datetime.date.today() + datetime.timedelta(+30) thisCampaign.setStartDate(strinput=StartDate) thisCampaign.setEndDate(strinput=EndDate) thisInternalURL = "/campaigns/detail/" + thisCampaignID thisCampaign.writeInternalURL(strinput=thisInternalURL) thisCampaign.put() self.response.write("Successfully created your Campaign") except: self.response.write("Error Creating Campaign") else: self.response.write( "Insufficient credit to create a new campaign")
def results(): name = request.form['name'] Gender = request.form['Gender'] PGender = request.form['pGender'] Height = request.form['Height'] pHeight = request.form['pHeight'] heightScale = request.form['heightScale'] Age = request.form['Age'] pAge = request.form['pAge'] religion = request.form['Religion'] religionScale = request.form['religionScale'] politics = request.form['Politics'] politicsScale = request.form['politicsScale'] introExtrovert = request.form['IntroExtro'] pIntroExtrovert = request.form['PIntroExtro'] introExtrovertScale = 1 #request.form['IntroExtroScale'] smoke = request.form['Smoker'] pSmoke = request.form['Psmoker'] smokeScale = request.form['smokeScale'] messyNeat = request.form['MessyNeat'] pMessyNeat = request.form['PMessyNeat'] messyNeatScale = request.form['messyNeatScale'] dogCat = request.form['DogCat'] dogCatScale = request.form['dogCatScale'] Robot = request.form['Robot'] pic = request.form['pic'] email = request.form['email'] #List of all of the values userValues = [ name, Gender, PGender, Height, pHeight, heightScale, Age, pAge, religion, religionScale, politics, politicsScale, introExtrovert, pIntroExtrovert, introExtrovertScale, smoke, pSmoke, smokeScale, messyNeat, pMessyNeat, messyNeatScale, dogCat, dogCatScale, Robot, email, pic ] #Convert values to proper form (turn to integer, list) for i in range(len(userValues)): #Integers if isinstance(userValues[i], int) or userValues[i].isdigit(): userValues[i] = int(userValues[i]) #List elif len(userValues[i]) > 0 and userValues[i][0] == "[": comma = userValues[i].index(",") num1 = "" num2 = "" for j in range(1, comma): num1 += userValues[i][j] for j in range(comma + 1, len(userValues[i]) - 1): num2 += userValues[i][j] num1 = int(num1) num2 = int(num2) userValues[i] = list(range(num1, num2 + 1)) #Create profile profile0 = Profile(userValues[0], userValues[1], userValues[2], userValues[3], userValues[4], userValues[5], userValues[6], userValues[7], userValues[8], userValues[9], userValues[10], userValues[11], userValues[12], userValues[13], userValues[14], userValues[15], userValues[16], userValues[17], userValues[18], userValues[19], userValues[20], userValues[21], userValues[22], userValues[23], userValues[24], userValues[25]) #Read the database list, append current profile with open('profileInformation.txt', 'rb') as input: data = pickle.load(input) if profile0 not in data: data.append(profile0) #Write list back to database with open('profileInformation.txt', 'wb') as output: pickle.dump(data, output, pickle.HIGHEST_PROTOCOL) #Read the database list with open('profileInformation.txt', 'rb') as input: profileList = pickle.load(input) #Junk profiles (for testing) # profile1 = Profile("joe","Male","Female",72,list(range(50,90)),5,20,list(range(18,50)),"Jewish",5,"Democrat",5,"Introvert","Extrovert",5,"No","Yes",5,"Messy","Messy",5,"Cat",5) # profile2 = Profile("Jane","Female","Male",68,list(range(40,100)),5,19,list(range(18,24)),"Buddhist",5,"Independent",9,"Extrovert","Extrovert",5,"Yes","Yes",5,"Neat","Neat",5,"Dog",5) # profile3 = Profile("Mary","Female","Male",62,list(range(73,77)),2,18,list(range(18,21)),"Christian",1,"Republican",10,"Extrovert","Extrovert",7,"No","No",5,"Neat","Messy",2,"Dog",4) # profile4 = Profile("Jackie","Female","Male",65,list(range(67,80)),5,42,list(range(18,30)),"Muslim",5,"Republican",5,"Introvert","Introvert",5,"No","No",5,"Neat","Neat",5,"Cat",5) # profileList = [profile1,profile2,profile3,profile4] newopposite = profile0.find_opposite(profileList) newhated = profile0.find_hated(profileList) newfriend = profile0.find_friend_zone(profileList) return render_template("results.html", answers=(userValues, newopposite, newhated, newfriend))