Пример #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
Пример #2
0
def post_drink(store_id):
    """
    Creates a drink
    """
    store = storage.get(Store, store_id)
    if not store:
        abort(404)
    if not request.get_json():
        abort(400, description="Not a JSON")
    if 'name' not in request.get_json():
        abort(400, description="Missing name")

    data = request.get_json()
    instance = Drink(**data)
    instance.store_id = store.id
    instance.save()
    return make_response(jsonify(instance.to_dict()), 201)
Пример #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
Пример #4
0
def generate_drink_from_data(data):
    f, success = try_parse_float(data[0].strip())
    if not success:
        return None

    d = Drink()
    time = int(f)
    d.time_of_drink = datetime.fromtimestamp(time)
    d.drinker = data[1].strip()
    d.abv, success = try_parse_float(data[2])
    if not success:
        return None

    d.volume_oz, success = try_parse_float(data[3])
    if not success:
        return None

    return d
Пример #5
0
def generate_dummy_drink_data(drinker_name='n', start_time=None):
    dummy_drinks = []

    if start_time is None:
        t = datetime.now().replace(hour=12)
    else:
        t = start_time

    for i in range(10):

        d = Drink()
        d.time_of_drink = t
        d.drinker = drinker_name
        d.volume_oz = 12.0 + (random.randint(0, 1) * 4.0)
        d.abv = 5.0 + (random.random() * 5.5) - 1.0
        dummy_drinks.append(d)
        minute_delta = (random.random() * 20) + 30
        t = t + timedelta(minutes=minute_delta)
    return calculate_bac_curve(dummy_drinks)
Пример #6
0
#!/usr/bin/python3
from models.base import BaseModel
from models.store import Store
from models.food import Food
from models.drink import Drink
from models.order import Order
from models import storage
from models.confirmation import Confirmation

my_store = Store(name="JV")
my_store.save()

my_food = Food(price=4000, store_id=my_store.id, name="Tinto")
my_food.save()

my_drink = Drink(price=5000, store_id=my_store.id, name="Cafe")
my_drink.save()

my_order = Order(order_number=1,
                 drink_id=my_drink.id,
                 store_id=my_store.id,
                 user_name="Juan")
my_order.save()
all_order = storage.all(Order)

my_confirmation = Confirmation(store_id=my_store.id,
                               order_id=my_order.id,
                               order_number=3,
                               status="In Progress")
my_confirmation.save()
Пример #7
0
    dave, errors = user_schema.load({
        'username': '******',
        'email': 'dave@email',
        'password': '******',
        'password_confirmation': 'pass'
    })



    #
    if errors:
        raise Exception(errors)

    pisco_sour = Drink(
        name='Pisco Sour',
        image='../assets/johann-trasch-pisco-sour-unsplash.jpg',
        ingredients='400ml of tonic water, 240ml lemon juice (equivalent to 8 lemons), 4 tablespoons of sugar syrup, Crushed ice, 400ml Alpro Soya Original Drink',
        recipe='1. Fill the glass 1/3 with crushed ice and add 1 teaspoon of sugar syrup, 2. Add the lime juice and pour over the tonic 3. Foam the Alpro Soya Original Drink and add the foam to the mocktail. Garnish with a slice of lime'
    )

    tea_n_tea = Drink(
        name='Tea \'n\' Tea from Pollen Street Social',
        image='../assets/johann-trasch-tea-n-tea-unsplash.jpg',
        ingredients='200ml Coconut Noir Tea (try Canton\'s), 10ml lemon juice, 50ml honey, Mint sprig',
        recipe='Brew your coconut noir tea and leave it to chill. Combine all ingredients in a cocktail shaker and shake. Pour over ice and garnish with mint sprig. Serve with a shortbread biscuit dusted with desiccated coconut.'
    )

    rose_lemon_spritzer = Drink(
        name='Rose Lemon Spritzer from Half Baked Harvest',
        image='../assets/paula-hayes-rose-lemon-unsplash.jpg',
        ingredients='2 tablespoons rose water * optional, 2 tablespoons fresh lemon juice, 1/2-2 ounces alcohol-free Vodka to taste!, 1-2 tablespoon honey or to taste (use agave if vegan), a few drops of blood orange or pomegranate juice for color (optional), 3/4 cup sparkling water or more to taste, fresh roses for garnish (optional)',
        recipe='Combine all the rose water, fresh lemon juice, vodka, honey and blood orange or pomegranate juice (if using) in a cocktail shaker and fill with ice. Shake until combined and then strain into a glass. Pour in the sparkling water. Garnish with fresh roses. DRINK!'