catalogApp.py
def addItem(newItemCategory_id):
    '''
    Adds an item to category matching newItemCategory_id.
    '''
    category = session.query(Category).filter_by(
        id=newItemCategory_id).one()
    if login_session['user_id'] != category.user_id:
        flash("Only the owner of %s category may add an item to it."
              % category.name)
        return redirect(url_for('showItems', category_id=category.id))
    if request.method == 'POST':
        newItem = Item(
            name=request.form['name'],
            description=request.form['description'],
            price=request.form['price'],
            img_url=request.form['img_url'],
            category_id=category.id,
            user_id=category.user_id)
        session.add(newItem)
        session.commit()
        flash("A new item has been added to this category.")
        return redirect(url_for('showItems', category_id=category.id))
    else:
        return render_template('newitem.html', category=category,
                               login_session=login_session)

    Adds an item to category matching newItemCategory_id.
    
Adds an item to category matching newItemCategory_id.
Adds an item to category matching newItemCategory_id .
def addItem(newItemCategory_id):
    category = session.query(Category).filter_by(
        id=newItemCategory_id).one()
    if login_session['user_id'] != category.user_id:
        flash("Only the owner of %s category may add an item to it."
              % category.name)
        return redirect(url_for('showItems', category_id=category.id))
    if request.method == 'POST':
        newItem = Item(
            name=request.form['name'],
            description=request.form['description'],
            price=request.form['price'],
            img_url=request.form['img_url'],
            category_id=category.id,
            user_id=category.user_id)
        session.add(newItem)
        session.commit()
        flash("A new item has been added to this category.")
        return redirect(url_for('showItems', category_id=category.id))
    else:
        return render_template('newitem.html', category=category,
                               login_session=login_session)
def addItem ( newItemCategory_id ) : category = session . query ( Category ) . filter_by ( id = newItemCategory_id ) . one ( ) if login_session [ 'user_id' ] != category . user_id : flash ( "Only the owner of %s category may add an item to it." % category . name ) return redirect ( url_for ( 'showItems' , category_id = category . id ) ) if request . method == 'POST' : newItem = Item ( name = request . form [ 'name' ] , description = request . form [ 'description' ] , price = request . form [ 'price' ] , img_url = request . form [ 'img_url' ] , category_id = category . id , user_id = category . user_id ) session . add ( newItem ) session . commit ( ) flash ( "A new item has been added to this category." ) return redirect ( url_for ( 'showItems' , category_id = category . id ) ) else : return render_template ( 'newitem.html' , category = category , login_session = login_session )
Adds an item to category matching newItemCategory_id.
Adds an item to category matching newItemCategory_id .
'''
    Adds an item to category matching newItemCategory_id.
    '''
newItemCategory_id