Example #1
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)
Example #2
0
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()

#print(my_order)