Beispiel #1
0
 def register_product(self):
     idd = random.randint(0, 1000000000)
     details = []
     details.append(idd)
     cls()
     print("==========================================")
     print("Enter Product Name: ", end="")
     details.append(input())
     print()
     print("Enter Product Description : ", end="")
     details.append(input())
     print()
     print("Enter Product Price : ", end="")
     details.append(input())
     print()
     details.append(Authentication.get_authenticated_user())
     details.append(-1)
     details.append(0)
     print("Enter Product Stock : ", end="")
     details.append(input())
     print()
     print("Enter Product Category : ", end="")
     details.append(input())
     print()
     Product.add_product(*details)
Beispiel #2
0
def handling_products(category_choice):

    while True:
        product_present = print_products_by_category(category_choice)

        t = PrettyTable(["Product Menu", "Type"])
        t.add_row(["New Product", "n/N"])
        if product_present:
            t.add_row(["Remove Product", "r/R"])
        t.add_row(["Back", "b/B"])
        print(t)

        print("-"*30)
        choice = input("Your Choice : ")
        print("-"*30)

        if len(choice) == 1:
            if choice in 'n/N':
                # new product
                print('-'*30)
                print("Enter Details for new Product:")
                print('-'*30)

                product_name = input("Product Name : ")

                ref_var = db.reference("Product").order_by_child('Name').equal_to(product_name).get()

                if ref_var:
                    print("Product Already Exists")
                    continue
                product_company = input("Product Company : ")
                product_about = input("Product About : ")
                product_specs = input("Product Specifications : ")
                product_price = input("Price : ")

                prod_object = Product()
                prod_id = prod_object.add_product(name=product_name, company=product_company, about=product_about, specification=product_specs, category=category_choice, price=product_price)

            elif choice in 'rR':
                # remove product
                print('-'*30)
                print("Enter Product Name to be Delete")
                print('-'*30)
                product_name = input("Product Name:")
                Product.remove_product(Product.get_product_id_by_product_name(product_name))
            elif choice in "bB":
                return
            else:
                print("Wrong Choice!!! Try Again")
                continue
        else:
            print("Please select one character only !!! Try Again")
            continue
    return
def create_product():
    form = ProductForm()

    if form.validate_on_submit():
        product = Product(
            id=None,
            title=form.title.data,
            content=form.content.data,
            price=form.price.data
        )

        product.add_product(User.get_id_by_email(session['email']))

        flash(f'{form.title.data} has been created!', 'success')
        return redirect(url_for('index'))

    return render_template(
        "product/edit_product.html",
        title="Create Product", form=form,
        legend="Add new product"
    )