Exemplo n.º 1
0
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
Exemplo n.º 2
0
    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
Exemplo n.º 3
0
    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