Exemplo n.º 1
0
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)
Exemplo n.º 2
0
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)
Exemplo n.º 3
0
def testshort():
    """ Home page
        return: template for index with required information
    """
    data = block_content().load_from_file()
    total = cart_count_total(Users_cart)
    return render_template('index.html',
                           box=data,
                           cartamount="{0:.2f}".format(total))
Exemplo n.º 4
0
def cart():
    """ displays objects in the cart
    """
    cart_count = len(Users_cart)
    total = cart_count_total(Users_cart)
    return render_template('cart.html',
                           data=Users_cart,
                           cartamount=cart_count,
                           cart_total="{0:.2f}".format(total))
Exemplo n.º 5
0
def display_block(oid):
    cart_count = len(Users_cart)
    total = cart_count_total(Users_cart)
    obj = block_content().grab_object(oid)
    return render_template('displayitem.html',
                           obj=obj,
                           cartamount=cart_count,
                           cart_total="{0:.2f}".format(total),
                           category=obj.get("category"))
Exemplo n.º 6
0
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)
Exemplo n.º 7
0
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)
Exemplo n.º 8
0
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)
Exemplo n.º 9
0
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)
Exemplo n.º 10
0
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)
Exemplo n.º 11
0
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)
Exemplo n.º 12
0
def delObjectbyid(ojid):
    total = cart_count_total(Users_cart)

    block_content().del_object(ojid)
    listofobjs = block_content().load_from_file()
    return redirect('/DeleteObject')