def get_all_drinks(cursor): cursor.execute("SELECT drinkName FROM Drinks WHERE drinkAvailable = 1") results = cursor.fetchall() drink_list = [] for result in results: new_drink = Drink() new_drink.name = result[0] drink_list.append(new_drink) return drink_list
def new(self, name = "", price = 0, bottle_size = 0, caffeine = 0, logo_url = ""): if cherrypy.request.method == 'GET': template = self.templateEnv.get_template('drinks/new.html') return template.render(drinks=[]) elif cherrypy.request.method == 'POST': drink = Drink() drink.name = name drink.price = price drink.bottle_size = bottle_size drink.caffeine = caffeine drink.logo_url = logo_url cherrypy.request.db.add(drink) else: pass
def new(self, name="", price=0, bottle_size=0, caffeine=0, logo_url=""): if cherrypy.request.method == 'GET': template = self.templateEnv.get_template('drinks/new.html') return template.render(drinks=[]) elif cherrypy.request.method == 'POST': drink = Drink() drink.name = name drink.price = price drink.bottle_size = bottle_size drink.caffeine = caffeine drink.logo_url = logo_url cherrypy.request.db.add(drink) else: pass