diff --git a/Lesson3/step3/project.py b/Lesson3/step3/project.py index 97ed550..7a6688e 100644 --- a/Lesson3/step3/project.py +++ b/Lesson3/step3/project.py @@ -295,13 +295,13 @@ def newMenuItem(restaurant_id): restaurant = session.query(Restaurant).filter_by(id=restaurant_id).one() if login_session['user_id'] != restaurant.user_id: return "
" - if request.method == 'POST': - newItem = MenuItem(name=request.form['name'], description=request.form['description'], price=request.form[ - 'price'], course=request.form['course'], restaurant_id=restaurant_id, user_id=restaurant.user_id) - session.add(newItem) - session.commit() - flash('New Menu %s Item Successfully Created' % (newItem.name)) - return redirect(url_for('showMenu', restaurant_id=restaurant_id)) + if request.method == 'POST': + newItem = MenuItem(name=request.form['name'], description=request.form['description'], price=request.form[ + 'price'], course=request.form['course'], restaurant_id=restaurant_id, user_id=restaurant.user_id) + session.add(newItem) + session.commit() + flash('New Menu %s Item Successfully Created' % (newItem.name)) + return redirect(url_for('showMenu', restaurant_id=restaurant_id)) else: return render_template('newmenuitem.html', restaurant_id=restaurant_id) diff --git a/Lesson4/step1/project.py b/Lesson4/step1/project.py index 1159323..b453e6a 100644 --- a/Lesson4/step1/project.py +++ b/Lesson4/step1/project.py @@ -294,13 +294,13 @@ def newMenuItem(restaurant_id): restaurant = session.query(Restaurant).filter_by(id=restaurant_id).one() if login_session['user_id'] != restaurant.user_id: return "" - if request.method == 'POST': - newItem = MenuItem(name=request.form['name'], description=request.form['description'], price=request.form[ - 'price'], course=request.form['course'], restaurant_id=restaurant_id, user_id=restaurant.user_id) - session.add(newItem) - session.commit() - flash('New Menu %s Item Successfully Created' % (newItem.name)) - return redirect(url_for('showMenu', restaurant_id=restaurant_id)) + if request.method == 'POST': + newItem = MenuItem(name=request.form['name'], description=request.form['description'], price=request.form[ + 'price'], course=request.form['course'], restaurant_id=restaurant_id, user_id=restaurant.user_id) + session.add(newItem) + session.commit() + flash('New Menu %s Item Successfully Created' % (newItem.name)) + return redirect(url_for('showMenu', restaurant_id=restaurant_id)) else: return render_template('newmenuitem.html', restaurant_id=restaurant_id) diff --git a/Lesson4/step2/project.py b/Lesson4/step2/project.py index 906cff5..e65ed78 100644 --- a/Lesson4/step2/project.py +++ b/Lesson4/step2/project.py @@ -361,13 +361,13 @@ def newMenuItem(restaurant_id): restaurant = session.query(Restaurant).filter_by(id=restaurant_id).one() if login_session['user_id'] != restaurant.user_id: return "" - if request.method == 'POST': - newItem = MenuItem(name=request.form['name'], description=request.form['description'], price=request.form[ - 'price'], course=request.form['course'], restaurant_id=restaurant_id, user_id=restaurant.user_id) - session.add(newItem) - session.commit() - flash('New Menu %s Item Successfully Created' % (newItem.name)) - return redirect(url_for('showMenu', restaurant_id=restaurant_id)) + if request.method == 'POST': + newItem = MenuItem(name=request.form['name'], description=request.form['description'], price=request.form[ + 'price'], course=request.form['course'], restaurant_id=restaurant_id, user_id=restaurant.user_id) + session.add(newItem) + session.commit() + flash('New Menu %s Item Successfully Created' % (newItem.name)) + return redirect(url_for('showMenu', restaurant_id=restaurant_id)) else: return render_template('newmenuitem.html', restaurant_id=restaurant_id)