def get(self): #attributes #1.Sunflower Variety/brand -brand #2.Sunflower Height per inches - height #3.Sunflower Population per acre -population #4.Sunflower Yield Pounds/lbs per acre - lbs #5.Crop Harvest Year - year sd1 = SunflowerData() sd1.brand = '' # creating attributes here... sd1.height = '' sd1.population = '' sd1.pounds = '' #calling a function #sd1.year = 2014 #lib.add_sunflower(sd1) p = ResultsPage() #I want to make an instance lib = Sunflowers() p.format_all() lib.calc_profit() if self.request.GET: #has to be in handler #stores info we got from the form brand = self.request.GET['brand'] #needs variables to work height = self.request.GET['height'] #needs variables to work population = self.request.GET['population'] pounds = self.request.GET['pounds'] year = self.request.GET['year'] else: self.response.write(p.body + "<div id='wrapper'>"+ "<h3>" "Sunflower Varieties Profit Calculator" + "</h3>" + ' ' + "<div id='name'>" + "Sunflower Variety/Brand:" + brand + "</div>" + "<div id='height2'>" + "Sunflower Height:" + height + "</div>" + "<div id='population2'>" + "Population per Acre:" + ' ' + population + "</div>" + "<div id='pounds2'>" + "Pounds per Acre:" + pounds + ' ' + "<div id='year2'>" + year + "</div>" "</br>" + "</div>" + p.close) #this is what I want printed whe repturned...I'm not sure how to do the css for this? self.response.write(p.head + p.body + p.close) #prints the information on the page
def get(self): # create our form page f = Form() # create the results view rp = ResultsPage() # GET Method to grab variables from user input if self.request.GET: # storing our info from the user inputs # call our BudgetBreak Object user = BudgetBreak() user.name = self.request.GET["name"] user.email = self.request.GET["email"] user.mon_exp = int(self.request.GET["monExp"]) user.mon_income = int(self.request.GET["monIncome"]) user.have_budget = self.request.GET["budget"] # RESULTS PAGE - INFORMATION # Print out if form has been submitted otherwise print out following else: rp.email = user.email # setting for print out of HTML elements on pages.py rp.annual = user.annual() rp.discretion = user.discretion() rp.name = user.name rp.mon_income = user.mon_income rp.mon_exp = user.mon_exp rp.calc_mortgage = user.calc_mortgage() # WOOOHOOOOOOO self.response.write(rp.print_out()) else: self.response.write(f.print_out()) # this will print out in browser
def get(self): uis = UserInfoStr()#this var holding the user info strings class from the lib file rp = ResultsPage()#this is making the result page usable in the main handler fp = FormPage()#this is making the form page usable in the main handler ui = UserInfo()#this var holding the user info class from the lib file if self.request.GET:#this is checking to see if info has been taken from the user ui.user_name = self.request.GET['user_name']#all of these vars are the information taken from the user. The information is then sent to the userInfo class ui.user_quest = self.request.GET['user_quest'] ui.user_color = self.request.GET['user_color'] ui.user_location = self.request.GET['user_location'] ui.sex = self.request.GET['sex'] ui.user_test = self.request.GET['user_test'] uis.add_user(ui)#this is taking the information from the UserInfo and sending it to the UserInfoStr rp.body = uis.user_output(uis.human_check())#this is taking the info from UserInfoStr and sending it to the results page all = rp.page_head + rp.body + rp.close all = all.format(**locals()) self.response.write(all)#this is posting the info to the screen else: self.response.write(fp.form_page_head + fp.page_form)#this is posting the form to the screen
def get(self): p = ResultsPage() fm = FavoriteMovies() #movie #year #director md1 = MovieData() md1.title = "The Princess Bride" md1.director = "Rob Reiner" md1.year = 1989 fm.add_movie(md1) md2 = MovieData() md2.title = "Dune" md2.director = "David Lynch" md2.year = 1986 fm.add_movie(md2) fm.calc_time() p.body = fm.compile_list() self.response.write(p.print_out())
def get(self): #create our form page f = Form() #create the results view rp = ResultsPage() #GET Method to grab variables from user input if self.request.GET: #storing our info from the user inputs #call our BudgetBreak Object user = BudgetBreak() user.name = self.request.GET['name'] user.email = self.request.GET['email'] user.mon_exp = int(self.request.GET['monExp']) user.mon_income = int(self.request.GET['monIncome']) user.have_budget = self.request.GET['budget'] #RESULTS PAGE - INFORMATION #Print out if form has been submitted otherwise print out following else: self.response.write(rp.print_out() + '<h3>Greetings, ' + user.name + '!</h3>' + 'From the information provided we have calculated the following information.<br/>' + 'Your email is: ' + user.email + '</p>' + 'The total of your recurring monthly expenses is: ' + str(user.mon_exp) + '<br />' + ' Your total monthly income is: ' + str(user.mon_income) + '<br />' + 'Your total monthly discretionary funds comes to ' + str(user.discretion()) + '<br />' + 'You ' + user.have_budget + ' use a budget to track your expenses and income.' + '<br />' +'Your estimated mortgage allowance should be ' + str(user.calc_mortgage()) + '<br />' + 'Your annual income is: ' + str(user.annual())) else: self.response.write(f.print_out())# this will print out in browser
def get(self): #to do list #enter in name #enter in grade 1 #enter in grade 2 #enter in grade 3 #enter in grade 4 gg = GetGrades() g = Grade() p = ResultsPage() f = FormPage() #page_head = p.head #page_form = p.form #page_close = p.close #page_result = p.result if self.request.GET: #stores info we got from form/information input g.name = self.request.GET['name'] #name g.age = self.request.GET['age'] #age g.g1 = self.request.GET['g1'] #grade1 g.g2 = self.request.GET['g2'] #grade2 g.g3 = self.request.GET['g3'] #grade3 g.g4 = self.request.GET['g4'] #grade4 avg = gg.calc_gpa(g) p.body = """<div class="form"><h1><p>Hello,<b> """ +g.name + """</b> Here is what you entered: <br> Grade 1:<b> """ +g.g1 + """</b><BR> Grade 2: <b>""" + g.g2 + """</b> <BR>Grade 3:<b> """ +g.g3 + """</b> <BR> Grade 4: <b>""" + g.g4 + """ <BR></b>We calculated that your GPA is<b> """+ str(avg) + """</b></b></p></div>""" self.response.write(p.print_out()) #p.body = gg.calc_gpa() + gg.get_grades() #below code is what prints out #self.response.write(p.print_out()) #self.response.write(page_head + page_result + '<h2> Hi ' + g.name + ",</h2><br> <h3>Here are the grades you entered:<BR> " + "<b>Age</b>" + g.age + "<b>Grade 1:</b> " +g.g1 + "<BR> <b>Grade 2:</b>" + g.g2 + "<BR><b> Grade 3:</b>" + g.g3 + "<BR><b>Grade 4:</b> " + g.g4 + page_close) else: self.response.write(f.print_out())
def get(self): #create an instance of our TeamData class for use in our main handler t = TeamData() #the below code happens if the user submits data via our field and prints the results page if self.request.GET: #Here (and the others below) we are setting our values equal to the input we received from the user via the form inputs p1 = PlayerData() p1.name = self.request.GET['p1_name'] #we use int() here (and below) to convert user input into numbers so we can use them in calculations. p1.kills = int(self.request.GET['p1_kills']) p1.assists = int(self.request.GET['p1_deaths']) p1.deaths = int(self.request.GET['p1_assists']) p1.heals = int(self.request.GET['p1_heals']) p1.abs = int(self.request.GET['p1_abs']) t.add_player( p1 ) #here (and the others below we are adding the player information gathered to our array of players in our TeamData class p2 = PlayerData() p2.name = self.request.GET['p2_name'] p2.kills = int(self.request.GET['p2_kills']) p2.assists = int(self.request.GET['p2_deaths']) p2.deaths = int(self.request.GET['p2_assists']) p2.heals = int(self.request.GET['p2_heals']) p2.abs = int(self.request.GET['p2_abs']) t.add_player(p2) p3 = PlayerData() p3.name = self.request.GET['p3_name'] p3.kills = int(self.request.GET['p3_kills']) p3.assists = int(self.request.GET['p3_deaths']) p3.deaths = int(self.request.GET['p3_assists']) p3.heals = int(self.request.GET['p3_heals']) p3.abs = int(self.request.GET['p3_abs']) t.add_player(p3) p4 = PlayerData() p4.name = self.request.GET['p4_name'] p4.kills = int(self.request.GET['p4_kills']) p4.assists = int(self.request.GET['p4_deaths']) p4.deaths = int(self.request.GET['p4_assists']) p4.heals = int(self.request.GET['p4_heals']) p4.abs = int(self.request.GET['p4_abs']) t.add_player(p4) p5 = PlayerData() p5.name = self.request.GET['p5_name'] p5.kills = int(self.request.GET['p5_kills']) p5.assists = int(self.request.GET['p5_deaths']) p5.deaths = int(self.request.GET['p5_assists']) p5.heals = int(self.request.GET['p5_heals']) p5.abs = int(self.request.GET['p5_abs']) t.add_player(p5) #if we gather inputs from the user, then p will equal the html from our ResultsPage class p = ResultsPage() #to compose our ResultsPage body we add in the results from out calculations with the TeamData class p.body = t.player_list() + t.calc_kills() + t.calc_deaths( ) + t.calc_abs() + t.calc_heals() #once everything is put together, we then write it to the page self.response.write(p.print_out()) else: #if we have not received data via form inputs, then our page body will be our form p = FormPage() #the below writes the form onto the page self.response.write(p.print_out())