diff --git a/Lesson4/step2/project.py b/Lesson4/step2/project.py index f4440b0..1e5f8a9 100644 --- a/Lesson4/step2/project.py +++ b/Lesson4/step2/project.py @@ -369,13 +369,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[ + 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)) + 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)