Пример #1
0
def addproducts():
    if "names" not in session:
        return redirect(url_for("login"))
    form=ProductForm()
    if form.validate_on_submit():
        names=form.names.data
        price=form.price.data
        quantity=form.quantity.data
        Product.create(names=names, price=price, quantity=quantity, owner=session ["id"])
        return redirect(url_for("products"))
    return render_template("addproduct.html", form=form)
Пример #2
0
def view_products():
    if "names" not in session:
        return redirect(url_for("login"))
    else:
        owner = session["id"]
        product = Product.select().where(Product.owner == owner)
        return render_template("view_products.html",
                               names=session["names"],
                               product=product)
Пример #3
0
def add_products():
    form = AddForm()
    if form.validate_on_submit():
        # everything is okay
        name = form.name.data
        sat = form.sat.data
        date = form.date.data
        owner = session["id"]
        #print("Name {0} sat {1} date {2} ".format(names,sat,date))

        try:
            Product.create(name=name, sat=sat, date=date, owner=owner)
            flash("SAT was saved successfully")
        except IntegrityError:
            flash("Unable to save")
    return render_template("add_products.html",
                           names=session["names"],
                           form=form)
Пример #4
0
def delete_post(id, blog_id):
    post = Post.get(Post.id == id)
    post.delete_instance()
    return make_response((blog_posts(blog_id)))


@app.route('/logout')
def logout():
    session.pop("names")
    session.pop("id")
    return redirect(url_for("login"))

if __name__ == '__main__':
    #User.drop_table()
    try:
        Product.create_table()
    except OperationalError:
        pass

    try:
        User.create_table()
    except OperationalError:
        pass

    try:
        Blog.create_table()
    except OperationalError:
        pass

    try:
        Post.create_table()
Пример #5
0
def products():
    if "names" not in session:
        return redirect(url_for("login"))
    else:
        products=Product.select()
        return render_template("products.html", names = session["names"], products=products)
Пример #6
0
def delete(id):
    del_product = Product.get(Product.id == id)
    del_product.delete_instance()
    return make_response(view_products())