From a17051c6c3f03ea6601e7ef2bc8122984caa03ad Mon Sep 17 00:00:00 2001 From: Alexey Drozdov Date: Fri, 4 Dec 2015 17:23:09 +0300 Subject: [PATCH 1/3] Add return statement if there was an error in the access token info --- Lesson2/step5/project.py | 1 + Lesson2/step6/project.py | 1 + Lesson2/step7/project.py | 1 + Lesson3/step1/project.py | 1 + Lesson3/step2Quiz/project.py | 1 + Lesson3/step2Solution/project.py | 1 + Lesson3/step3/project.py | 1 + Lesson4/step1/project.py | 1 + Lesson4/step2/project.py | 1 + 9 files changed, 9 insertions(+) diff --git a/Lesson2/step5/project.py b/Lesson2/step5/project.py index dc3dfa7..8883695 100644 --- a/Lesson2/step5/project.py +++ b/Lesson2/step5/project.py @@ -71,6 +71,7 @@ def gconnect(): if result.get('error') is not None: response = make_response(json.dumps(result.get('error')), 500) response.headers['Content-Type'] = 'application/json' + return response # Verify that the access token is used for the intended user. gplus_id = credentials.id_token['sub'] diff --git a/Lesson2/step6/project.py b/Lesson2/step6/project.py index 7d849ef..2f383cd 100644 --- a/Lesson2/step6/project.py +++ b/Lesson2/step6/project.py @@ -68,6 +68,7 @@ def gconnect(): if result.get('error') is not None: response = make_response(json.dumps(result.get('error')), 500) response.headers['Content-Type'] = 'application/json' + return response # Verify that the access token is used for the intended user. gplus_id = credentials.id_token['sub'] diff --git a/Lesson2/step7/project.py b/Lesson2/step7/project.py index cdedcae..88d005d 100644 --- a/Lesson2/step7/project.py +++ b/Lesson2/step7/project.py @@ -66,6 +66,7 @@ def gconnect(): if result.get('error') is not None: response = make_response(json.dumps(result.get('error')), 500) response.headers['Content-Type'] = 'application/json' + return response # Verify that the access token is used for the intended user. gplus_id = credentials.id_token['sub'] diff --git a/Lesson3/step1/project.py b/Lesson3/step1/project.py index 7a775d4..de0fa55 100644 --- a/Lesson3/step1/project.py +++ b/Lesson3/step1/project.py @@ -69,6 +69,7 @@ def gconnect(): if result.get('error') is not None: response = make_response(json.dumps(result.get('error')), 500) response.headers['Content-Type'] = 'application/json' + return response # Verify that the access token is used for the intended user. gplus_id = credentials.id_token['sub'] diff --git a/Lesson3/step2Quiz/project.py b/Lesson3/step2Quiz/project.py index dd3fcf1..d20e917 100644 --- a/Lesson3/step2Quiz/project.py +++ b/Lesson3/step2Quiz/project.py @@ -72,6 +72,7 @@ def gconnect(): if result.get('error') is not None: response = make_response(json.dumps(result.get('error')), 500) response.headers['Content-Type'] = 'application/json' + return response # Verify that the access token is used for the intended user. gplus_id = credentials.id_token['sub'] diff --git a/Lesson3/step2Solution/project.py b/Lesson3/step2Solution/project.py index c7757ad..feea0a0 100644 --- a/Lesson3/step2Solution/project.py +++ b/Lesson3/step2Solution/project.py @@ -67,6 +67,7 @@ def gconnect(): if result.get('error') is not None: response = make_response(json.dumps(result.get('error')), 500) response.headers['Content-Type'] = 'application/json' + return response # Verify that the access token is used for the intended user. gplus_id = credentials.id_token['sub'] diff --git a/Lesson3/step3/project.py b/Lesson3/step3/project.py index 7a6688e..78398d1 100644 --- a/Lesson3/step3/project.py +++ b/Lesson3/step3/project.py @@ -73,6 +73,7 @@ def gconnect(): if result.get('error') is not None: response = make_response(json.dumps(result.get('error')), 500) response.headers['Content-Type'] = 'application/json' + return response # Verify that the access token is used for the intended user. gplus_id = credentials.id_token['sub'] diff --git a/Lesson4/step1/project.py b/Lesson4/step1/project.py index 1159323..c0f6982 100644 --- a/Lesson4/step1/project.py +++ b/Lesson4/step1/project.py @@ -68,6 +68,7 @@ def gconnect(): if result.get('error') is not None: response = make_response(json.dumps(result.get('error')), 500) response.headers['Content-Type'] = 'application/json' + return response # Verify that the access token is used for the intended user. gplus_id = credentials.id_token['sub'] diff --git a/Lesson4/step2/project.py b/Lesson4/step2/project.py index 906cff5..656643a 100644 --- a/Lesson4/step2/project.py +++ b/Lesson4/step2/project.py @@ -145,6 +145,7 @@ def gconnect(): if result.get('error') is not None: response = make_response(json.dumps(result.get('error')), 500) response.headers['Content-Type'] = 'application/json' + return response # Verify that the access token is used for the intended user. gplus_id = credentials.id_token['sub'] From 6898d9fa460df0111c4997ace3db57f034f1952c Mon Sep 17 00:00:00 2001 From: Philip Mallory Date: Fri, 19 Aug 2016 12:07:41 -0700 Subject: [PATCH 2/3] bugfix: bad parentheses https://udacity.atlassian.net/browse/FSND-41 --- Lesson4/step2/project.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Lesson4/step2/project.py b/Lesson4/step2/project.py index 656643a..b429dff 100644 --- a/Lesson4/step2/project.py +++ b/Lesson4/step2/project.py @@ -248,7 +248,7 @@ def gdisconnect(): if result['status'] != '200': # For whatever reason, the given token was invalid. response = make_response( - json.dumps('Failed to revoke token for given user.', 400)) + json.dumps('Failed to revoke token for given user.'), 400) response.headers['Content-Type'] = 'application/json' return response From cd5540c937c8b36b301fbe42156c2ec69260c83d Mon Sep 17 00:00:00 2001 From: Megan Chang Date: Wed, 17 May 2017 23:05:37 -0700 Subject: [PATCH 3/3] Fixed indentation for newMenuItem POST method --- Lesson4/step2/project.py | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/Lesson4/step2/project.py b/Lesson4/step2/project.py index b429dff..35f040e 100644 --- a/Lesson4/step2/project.py +++ b/Lesson4/step2/project.py @@ -362,13 +362,12 @@ 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)