def EditItemHandler(itemid): #TO-DO if not IsUserLoggedIn(): return redirect('/catalog') else: print 'reached edit here..' if request.method == 'GET': catitem = getItemById(itemid) if catitem: catalog = getCatalog() return render_template("edititem.html", \ catalog=catalog, catitem=catitem) else: #though it is not possible to reach here, # just in case handle it return redirect('/catalog') else: #for now redirect to root.. item_name = request.form['ItemName'] item_desc = request.form['ItemDesc'] cat_id = request.form['ItemCat'] editItem(itemid, item_name, item_desc, cat_id) return redirect('/catalog') return redirect('/catalog')
def EditItemHandler(itemid): '''Edit individual item - logged users http://localhost:8000/catalog/Snowboard/edit (logged in)''' if not IsUserLoggedIn(): return redirect('/catalog') else: print 'reached edit here..' if request.method == 'GET': catitem = GetItemById(itemid) if catitem: catalog = getCatalog() return render_template("edititem.html", \ catalog=catalog, catitem=catitem) else: #though it is not possible to reach here, # just in case handle it return redirect('/catalog') else: #for now redirect to root.. item_name = request.form['ItemName'] item_desc = request.form['ItemDesc'] cat_id = request.form['ItemCat'] EditItem(itemid, item_name, item_desc, cat_id) return redirect('/catalog')
def CatalogItemsHander(catagoryname): '''Show items in selected category''' catalog = getCatalog() catalogitems = getItemsByCat(catagoryname) IsUserLoggedIn() return render_template("catalogitems.html", catalog=catalog, \ catalogitems=catalogitems, \ session=login_session)
def CatalogHander(): '''Show all categories and items''' print "Show all categories and latest items - unlogged/logged users" catalog = getCatalog() catalogitems = getLatestItems() IsUserLoggedIn() return render_template("catalog.html", catalog=catalog, \ catalogitems=catalogitems, \ session=login_session)
def CatalogHander(): '''Show all categories and items http://localhost:8000/ http://localhost:8000/ (logged in)''' catalog = getCatalog() catalogitems = GetLatestItems() IsUserLoggedIn() return render_template("catalog.html", catalogitems=catalogitems , \ catalog=catalog, \ session=login_session)
def CatalogItemsHander(catagoryname): '''Show items in selected category http://localhost:8000/catalog/Snowboarding/items''' catalog = getCatalog() catalogitems = GetItemsByCat(catagoryname) IsUserLoggedIn() return render_template("catalogitems.html", \ category=catagoryname, \ catalog=catalog, \ catalogitems=catalogitems, \ session=login_session)
def AddItemHandler(): if not IsUserLoggedIn(): return redirect('/catalog') else: print 'reached here..' if request.method == 'GET': catalog = getCatalog() return render_template("additem.html", catalog=catalog) else: item_name = request.form['ItemName'] item_desc = request.form['ItemDesc'] cat_id = request.form['ItemCat'] addItem(item_name, item_desc, cat_id) return redirect('/catalog')
def AddItemHandler(): '''Add new item http://localhost:8000/catalog/Snowboard/Add (logged in)''' if not IsUserLoggedIn(): return redirect('/catalog') else: print 'reached here..' if request.method == 'GET': catalog = getCatalog() return render_template("additem.html", catalog=catalog) else: item_name = request.form['ItemName'] item_desc = request.form['ItemDesc'] cat_id = request.form['ItemCat'] AddItem(item_name, item_desc, cat_id) return redirect('/catalog')