def liquor_types(self, environ, start_response): content_type = 'text/html' text = """ <!DOCTYPE HTML> <html> <head> <title>Liquor Types List</title> <style type='text/css'> h1 {text-decoration:underline; text-align:center; color:red;} body { font-size:14px; } </style> </head> <body> <h1>List of Liquor Types</h1> <ul> <li><a href='/'>Home</a></li> <li><a href='/recipes'>List Recipes</a></li> <li><a href='/inventory'>List Inventory</a></li> <li><a href='/liquor_types'>List Liquor Types</a></li> </ul> <hr /> <ul> """ bottle_types = list(db.get_bottle_types()) for (m, l, t) in bottle_types: text += "\t<li>" + t + "</li>\n" text += '</ul>' text += '</body></html>' data = text start_response('200 OK', list(html_headers)) return [data]
def liq_typs(): tcontent = [] for i in db.get_bottle_types(): tcontent.append(i) vars = dict(title = 'Bottle Types', theaders=["MFG","Liquor","Type"],tcontent = tcontent) return JinjaLoader('bottle_type_pages.html', vars)
def show_bottle_types(self, environ, start_response): vars = {} if environ['REQUEST_METHOD'].endswith('POST'): vars['error'] = self.do_add_bottle_type(environ) vars['bottle_types'] = db.get_bottle_types() data = self._render('bottletypes.html', 'Show Bottle Types', vars) start_response('200 OK', list(html_headers)) return [data]
def add_recipe(self, environ, start_response): liquor_types = set() for bottle in db.get_bottle_types(): liquor_types.add(bottle[2]) liquor_types = list(liquor_types) liquor_types.sort() vars = {'liquor_types': liquor_types} data = self._render('form_recipe.html', 'Add To Inventory', vars) start_response('200 OK', list(html_headers)) return [data]
def liquor_types(self, environ, start_response): title = "liquor" content = "<ul>" bottle_types = db.get_bottle_types() for (mfg, lqr,typ) in bottle_types: content += "<li>%s, %s, %s</li>"%(mfg,lqr,typ) content += "</ul>" data = begining % (title,title) + content + end start_response('200 OK', list(html_headers)) return [data]
def add_inventory(self, environ, start_response): manufacturers = [] liquors = [] for bottle in db.get_bottle_types(): manufacturers.append(bottle[0]) liquors.append(bottle[1]) manufacturers.sort() liquors.sort() vars = {'manufacturers': manufacturers, 'liquors': liquors} data = self._render('form_inventory.html', 'Add To Inventory', vars) start_response('200 OK', list(html_headers)) return [data]
def liquor_types(self, environ, start_response): content_type = 'text/html' data = """ <table border=\"1\" cellpadding =\"5\"> <tr><th>Manfacturer</th><th>Liquor</th><th>Type</th></tr> """ for item in db.get_bottle_types(): data = data + "<tr><td> %s </td><td> %s </td><td> %s </td></tr>" % item data = data + "</table>" #data = data + printMenu() data = self.buildHtmlPage("Liquor Types","",data) start_response('200 OK', [('Content-type', content_type)]) return [data]
def need_ingredients(self): # the list we're hoping to return missing = [] found = False # go through the ingredients for ing in self.ingredients: found = False # make a tuple to be added eventually need = (ing[0], db.convert_to_ml(ing[1])) original_needed_amount = need[1] # ignore this for a while, it will come in handy soon # now compare the ingredient type to the types we hve for type in db.get_bottle_types(): # if we know such type exists and that type is in our inventory (by a mfg and a liquor) if (type[2] == need[0]) and db.check_inventory(type[0], type[1]): # print "checking "+type[2]+" with mfg= "+type[0]+ " with liquor "+type[1] # see how much liquor is available by that particular mfg and liquor available_amount = db.get_liquor_amount(type[0], type[1]) # if we have more than or equal amount of that liquor from that particular mfg and liquor if available_amount >= original_needed_amount: # print "found it :)" # then we're done here, let's move on to the next ingredient (break out of the current/types loop) found = True break else: # if the amount is not enough # how much is missing? (difference between what we need and what we have) difference_amount = original_needed_amount - available_amount # we will try to find the mfg and liquor with the minimum missing amount. Otherwise, just leave it alone. # I know I could've used min() but this will make thigns look simpler if difference_amount < need[1]: # print "we will replace the current "+str(need[1])+" with the new differnece: "+str(difference_amount) need = (need[0], difference_amount) # else: # print "we will not replace "+str(need[1])+" with the new difference "+str(difference_amount) if not found: missing.append(need) return missing
def liquort(self, environ, start_response): if self.get_name(environ) != False: namenow = self.get_name(environ) addin="" for item in db.get_bottle_types(): addin += "<li><div class=\"ui-grid-b\"><div class=\"ui-block-a\" style=\"width:50%\">" + item[0] + "</div><div class=\"ui-block-b\" style=\"width:25%\">" + item[1] + "</div><div class=\"ui-block-c\" style=\"width:25%\">" + item[2] + "</div></li>" vars = dict(title="LiquorTypes",name=namenow,liquort=addin) template = env.get_template("liquortypes.html") data = template.render(vars) content_type = 'text/html' start_response('200 OK', list(html_headers)) return [str(data)] else: headers = list(html_headers) headers.append(('Location', '/login')) start_response('302 Found', headers) return ["Redirect to /login..."]
def rpc_GetLiquorTypes(self): return list(db.get_bottle_types());