def addItem():
    """Displays the add item page."""

    if request.method == 'POST':
        # verify the user has logged in
        if 'username' not in login_session:
            return redirect(url_for('showLogin'))

        if request.form.get('add', None) == 'add':
            name = bleach.clean(request.form['name'], 
                                strip=True)

            # verify that cleaned name is not blank
            if not name:
                flash("Name field is required")
                categories = get_categories()
                return render_template('addItem.html',
                                       categories=categories)

            #build the new item
            item = Item()
            item.name = name
            item.description = bleach.clean(request.form['description'],
                                            strip=True)
            item.image_url = bleach.clean(request.form['imageUrl'],
                                          strip=True)
            item.category_id = bleach.clean(request.form['category'],
                                            strip=True)

            item.last_update = get_time()
            item.owner_id = login_session['user_id']
            session.add(item)
            session.commit()

            return redirect(url_for('showItem', item_id=item.id))
        else:
            return redirect(url_for('showIndex'))
    else:
        categories = get_categories()
        return render_template('addItem.html', categories=categories)