Jan-09-2019, 07:05 PM
Hello!
I have a repo on git hub, and I'm having issues with the authorization for the edit and delete methods.
While the above repo doesn't reflect the following, I have been fiddling with the following code to sort out the issue
, as it seems like such a simple fix. Any help would be appreciated
I have a repo on git hub, and I'm having issues with the authorization for the edit and delete methods.
While the above repo doesn't reflect the following, I have been fiddling with the following code to sort out the issue
#Edit a cuisine @app.route('/cuisine/<int:id>/edit/', methods = ['GET', 'POST']) def editCuisine(id): if 'username' not in login_session: return redirect('login') editedCuisine = session.query(Cuisine).filter_by(id = id).one() # Check if the logged in user is the owner of item creator = getUserInfo(editedCuisine.user_id) user = getUserInfo(login_session['user_id']) # If logged in user is not item owner redirect them if creator.id != login_session['user_id']: flash ("This is not yours to edit. This belongs to %s" % creator.name) return redirect(url_for('editCuisine')) # Method for posting if request.method == 'POST': if request.form['name']: editedCuisine.name = request.form['name'] if request.form['description']: editedCuisine.description = request.form['description'] flash('Cuisine Successfully Edited %s' % editedCuisine.name) return redirect(url_for('showCuisines')) else: return render_template('editCuisine.html', cuisine = editedCuisine)When I try and edit and item, I get the following error:
Output:sqlalchemy.exc.OperationalError: (sqlite3.OperationalError) no such column: cuisine.user_id [SQL: 'SELECT cuisine.id AS cuisine_id, cuisine.name AS cuisine_name, cuisine.description AS cuisine_description, cuisine.user_id AS cuisine_user_id \nFROM cuisine \nWHERE cuisine.id = ?'] [parameters: (2,)]
I'm at my whits end with this 
