def addObject(): """ Adds object to the website """ total = cart_count_total(Users_cart) form = BlockForm() allcats = returnallcatlist() if request.method == 'POST': if form.validate_on_submit(): newobj = block_content(item={ 'name': form.name.data, 'picture': form.picture.data, 'about': form.discription.data, 'price': form.price.data, 'color': form.Color.data, 'size': form.Size.data, 'brand': form.Brand.data }, category=form.cat.data) objdic = newobj.to_dict() newobj.save_to_file(objdic) data = block_content().load_from_file() return redirect('/items') else: error = "please fill out each field, or please enter a valid price (ie. 9.99)" return render_template('addobj.html', form=form, cartamount=total, error=error, categories=allcats) else: return render_template('addobj.html', form=form, cartamount=total, categories=allcats)
def removec(): total = cart_count_total(Users_cart) listofobjs = block_content().load_from_file() allcats = returnallcatlist() return render_template('removecat.html', data=listofobjs, cartamount="{0:.2f}".format(total), categories=allcats)
def display_cat(catname): cart_count = len(Users_cart) total = cart_count_total(Users_cart) cat_list = grab_cat(catname) allcats = returnallcatlist() return render_template("cat.html", data=cat_list, cartamount="{0:.2f}".format(total), cat=catname, categories=allcats)
def items_manager(): """ returns page to view all items on website """ total = cart_count_total(Users_cart) listofobjs = block_content().load_from_file() allcats = returnallcatlist() return render_template('items.html', data=listofobjs, cartamount="{0:.2f}".format(total), categories=allcats)
def settings(): """ displays the settings page with options to different settings """ total = cart_count_total(Users_cart) listofobjs = block_content().load_from_file() allcats = returnallcatlist() return render_template('objsettings.html', data=listofobjs, cartamount="{0:.2f}".format(total), categories=allcats)
def delObject(): """ returns page to select object to delete """ total = cart_count_total(Users_cart) listofobjs = block_content().load_from_file() allcats = returnallcatlist() return render_template('delobj.html', data=listofobjs, cartamount="{0:.2f}".format(total), categories=allcats)
def addcat(): total = cart_count_total(Users_cart) form = addcatform() allcats = returnallcatlist() if request.method == 'POST': if form.validate_on_submit(): add_cat(form.name.data) return redirect('/settings') else: error = "please fill out each field" return render_template('addcat.html', form=form, cartamount=total, error=error, categories=allcats) else: return render_template('addcat.html', form=form, cartamount=total, categories=allcats)
def items_update(object_id): total = cart_count_total(Users_cart) form = UpdateForm() obj = block_content().grab_object(object_id) allcats = returnallcatlist() if request.method == 'POST': if form.validate_on_submit(): item_up = { 'name': form.name.data, 'picture': form.picture.data, 'about': form.discription.data, 'price': form.price.data, 'color': form.Color.data, 'size': form.Size.data, 'brand': form.Brand.data } updated = block_content().updateobj(object_id, item_up) catadd = block_content().grab_object(object_id) update_cat(form.cat.data, object_id) return redirect('/UpdateObject') else: form.discription.data = item_value_grab(obj, "about") error = "please Fill out the objects fully, or please enter a valid price (ie. 9.99)" return render_template('updateitem.html', form=form, error=error, obj=obj, cartamount="{0:.2f}".format(total), categories=allcats) else: form.discription.data = item_value_grab(obj, "about") return render_template('updateitem.html', obj=obj, form=form, cartamount="{0:.2f}".format(total), categories=allcats)