catalogApp.py
def editItem(category_id, item_id):
    '''
    Edits item with matching item_id.
    '''
    itemToEdit = session.query(Item).filter_by(id=item_id).one()
    belongsToCategory = session.query(Category).filter_by(
        id=itemToEdit.category_id).one()
    if login_session['user_id'] != itemToEdit.user_id:
        flash("Only the owner of %s category may edit this item."
              % belongsToCategory.name)
        return redirect(url_for('showItems', category_id=belongsToCategory.id))
    if request.method == 'POST':
        if request.form['name']:
            itemToEdit.name = request.form['name']
        if request.form['price']:
            itemToEdit.price = request.form['price']
        if request.form['description']:
            itemToEdit.description = request.form['description']
        if request.form['img_url']:
            itemToEdit.img_url = request.form['img_url']
        session.add(itemToEdit)
        session.commit()
        flash("You have made changes to an item in this category.")
        return redirect(url_for('showItems', category_id=category_id))
    else:
        return render_template('edititem.html', item=itemToEdit,
                               login_session=login_session)

    Edits item with matching item_id.
    
Edits item with matching item_id.
Edits item with matching item_id .
def editItem(category_id, item_id):
    itemToEdit = session.query(Item).filter_by(id=item_id).one()
    belongsToCategory = session.query(Category).filter_by(
        id=itemToEdit.category_id).one()
    if login_session['user_id'] != itemToEdit.user_id:
        flash("Only the owner of %s category may edit this item."
              % belongsToCategory.name)
        return redirect(url_for('showItems', category_id=belongsToCategory.id))
    if request.method == 'POST':
        if request.form['name']:
            itemToEdit.name = request.form['name']
        if request.form['price']:
            itemToEdit.price = request.form['price']
        if request.form['description']:
            itemToEdit.description = request.form['description']
        if request.form['img_url']:
            itemToEdit.img_url = request.form['img_url']
        session.add(itemToEdit)
        session.commit()
        flash("You have made changes to an item in this category.")
        return redirect(url_for('showItems', category_id=category_id))
    else:
        return render_template('edititem.html', item=itemToEdit,
                               login_session=login_session)
def editItem ( category_id , item_id ) : itemToEdit = session . query ( Item ) . filter_by ( id = item_id ) . one ( ) belongsToCategory = session . query ( Category ) . filter_by ( id = itemToEdit . category_id ) . one ( ) if login_session [ 'user_id' ] != itemToEdit . user_id : flash ( "Only the owner of %s category may edit this item." % belongsToCategory . name ) return redirect ( url_for ( 'showItems' , category_id = belongsToCategory . id ) ) if request . method == 'POST' : if request . form [ 'name' ] : itemToEdit . name = request . form [ 'name' ] if request . form [ 'price' ] : itemToEdit . price = request . form [ 'price' ] if request . form [ 'description' ] : itemToEdit . description = request . form [ 'description' ] if request . form [ 'img_url' ] : itemToEdit . img_url = request . form [ 'img_url' ] session . add ( itemToEdit ) session . commit ( ) flash ( "You have made changes to an item in this category." ) return redirect ( url_for ( 'showItems' , category_id = category_id ) ) else : return render_template ( 'edititem.html' , item = itemToEdit , login_session = login_session )
Edits item with matching item_id.
Edits item with matching item_id .
'''
    Edits item with matching item_id.
    '''
category_id
item_id