def newCuisine():
    if 'username' not in login_session:
        return redirect('/login')
    if request.method == 'POST':
        newCuisine = Cuisine(name=request.form['name'],
                             user_id=login_session['user_id'])
        session.add(newCuisine)
        flash('New Cuisine %s Successfully Created' % newCuisine.name)
        session.commit()
        return redirect(url_for('showCuisines'))
    else:
        return render_template('newCuisine.html')
Exemplo n.º 2
0
def addCuisine():
    user_id = getUserID(login_session.get('email'))
    if not user_id:
        return redirect(url_for('showCuisines'))
    if request.method == 'POST':
        user_id = getUserID(login_session['email'])
        cuisine1 = Cuisine(user_id=user_id, name=request.form['name'])
        session.add(cuisine1)
        session.commit()
        flash("another cuisine added")
        return redirect(url_for('showCuisines'))
    else:
        return render_template('cuisineform.html')
Exemplo n.º 3
0
def newCuisine():
    if 'username' not in login_session:
        return redirect('login')
        flash('You must sign in to add a new cuisine')
    if request.method == 'POST':
        newCuisine = Cuisine(name=request.form['name'],
                             description=request.form['description'])
        session.add(newCuisine)
        flash('New Cuisine %s Successfully Created' % newCuisine.name)
        session.commit()
        return redirect(url_for('showCuisines'))
    else:
        return render_template('newCuisine.html')
Exemplo n.º 4
0
def addNewCuisine():
    if 'username' not in login_session:
        return redirect('/login')
    session = DBSession()
    if request.method == 'POST':
        newCuisine = Cuisine(name=request.form['name'],
                             description=request.form['description'],
                             imageUrl=request.form['imageUrl'],
                             created_by=getUserId(login_session['email']))
        session.add(newCuisine)
        session.commit()
        flash('New Cuisine has been added!')
        return redirect(url_for('showCuisines'))
    else:
        return render_template('newcuisine.html')
Exemplo n.º 5
0
def addCuisine(name):
    '''Add a cuisine to the database

    Returns the id of the cuisine
    '''
    session = getRestaurantDBSession()

    cuisine = Cuisine(name=name)

    session.add(cuisine)
    session.flush()
    cuisine_id = cuisine.id
    session.commit()
    session.close()

    return cuisine_id
Exemplo n.º 6
0
def newCuisine():
    """New Cuisine page route"""
    # Redirects to the login page if the user is not logged in
    if 'username' not in login_session:
        return redirect('/login')

    # Creates the new cuisine form
    form = CuisineForm()
    # POST method functionality
    if request.method == 'POST':
        # Checks if all the fields are valid
        if form.validate_on_submit():
            # Creates the new cuisine and commits the changes
            cuisine = Cuisine(name=form.name.data,
                              user_id=login_session['user_id'])
            session.add(cuisine)
            session.commit()
            flash('New Cuisine %s Successfully Created' % (cuisine.name))
            return redirect(url_for('showRecipes', cuisine_id=cuisine.id))
    return render_template("newCuisine.html", form=form)
Exemplo n.º 7
0
engine = create_engine('sqlite:///catalogwithuserdb.db')
Base.metadata.bind = engine
DBSession = sessionmaker(bind=engine)
session = DBSession()

# Create dummy user
user = User(name="Heba",
            email="*****@*****.**",
            picture=("https://www.pinclipart.com/picdir/middle/200-2008697_"
                     "account-customer-login-man-user-icon-login-icon.png"))
session.add(user)
session.commit()

# Create African Cuisine
cuisine1 = Cuisine(user_id=1, name="African Cuisine")
session.add(cuisine1)
session.commit()

af_recipe1 = Recipe(user_id=1,
                    name="East African Braised Chicken",
                    description=("The Indian spice trade carried curry "
                                 "throughout East Africa. Popular curry "
                                 "dishes like this aromatic chicken "
                                 "braised in broth with dates and "
                                 "raisins also combines traditional "
                                 "African braising techniques."),
                    cuisine=cuisine1)
session.add(af_recipe1)
session.commit()
Exemplo n.º 8
0
session = DBSession()

# Create dummy user

User1 = User(name='Pratik Shetty',
             email='*****@*****.**',
             picture='''https://pbs.twimg.com/profile_images/
        2671170543/18debd694829ed78203a5a36dd364160_400x400.png''',
             password='******')
session.add(User1)
session.commit()

# Menu for UrbanBurger

cuisine1 = Cuisine(user_id=1, name='American')

session.add(cuisine1)
session.commit()

foodItem2 = FoodItem(user_id=1,
                     name='Veggie Burger',
                     description='''Juicy grilled veggie patty
                     with tomato mayo and lettuce''',
                     ingredient='veggie patty,tomato',
                     cuisine=cuisine1)

session.add(foodItem2)
session.commit()

foodItem1 = FoodItem(user_id=1,
# A DBSession() instance establishes all conversations with the database
# and represents a "staging zone" for all the objects loaded into the
# database session object. Any change made against the objects in the
# session won't be persisted into the database until you call
# session.commit(). If you're not happy about the changes, you can
# revert all of them back to the last commit by calling
# session.rollback()
session = DBSession()

# Create a user
User1 = User(name = "Emma Johnson", email = "*****@*****.**", picture = "http://onelittleproject.com/wp-content/uploads/2013/12/DSC_4446.jpg")
session.add(User1)
session.commit()

# American Cuisine Recipes
cuisine1 = Cuisine(user_id=1, name = "American")
session.add(cuisine1)
session.commit()

recipe1 = Recipe(user_id=1, name = "Pepper Poppers", description = "Creamy stuffed jalapenos", preptime = "40 mins", course = "Appetizers", cuisine = cuisine1)
session.add(recipe1)
session.commit()

recipe2 = Recipe(user_id=1, name = "Glazed Chicken Wings", description = "Saucy dipped chicken wings", preptime = "1 hour", course = "Appetizers", cuisine = cuisine1)
session.add(recipe2)
session.commit()

recipe3 = Recipe(user_id=1, name = "Buffalo Wings", description = "Fried chicken tenders coated in spicy Nashville Hot seasoning with lettuce, tomatoes and pickles; served on a brioche bun", preptime = "2 hours", course = "Entrees", cuisine = cuisine1)
session.add(recipe3)
session.commit()
Exemplo n.º 10
0
from database_setup import Base, Cuisine, Dish, User

engine = create_engine('sqlite:///cuisines.db')
Base.metadata.bind = engine

DBSession = sessionmaker(bind=engine)
session = DBSession()

# Dummy user account that will attach to all the dishes created in this file
user1 = User(name="Python Script User", email="dummy")
session.add(user1)
session.commit()

# Italian
cuisine1 = Cuisine(name="Italian")
session.add(cuisine1)
session.commit()

dish1 = Dish(user_id=1,
             name="Baccala alla Vicentina",
             description="""Stockfish (dried cod) covered with flour, placed on
             top of anchovies, onions, and parsley, simmered in milk for 4
             hours, and topped with parmesan.""",
             cuisine=cuisine1)
session.add(dish1)
session.commit()

dish2 = Dish(user_id=1,
             name="Bistecca alla Fiorentina",
             description="""Thick T-bone brushed with oil by rosemary sprigs,