示例#1
0
def handling_category():

    while True:
        print("-"*30)
        c = Category.get_all_categories()

        t = PrettyTable(["Category Menu", "Type"]) 
        if c:
            t.add_row(["Select a Category", "s/S"])
        t.add_row(["Create New Category", "n/N"])
        t.add_row(["Return Back", "b/B"])
        print(t)

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

        category_choice = ""

        if len(choice) == 1:
            if choice in 'sS':
                # select category
                print("Type the Category You Want to Select:")
                print("-"*30)
                category_choice = input("Your Choice : ")
                print("-"*30)
                handling_products(category_choice)

            elif choice in 'nN':
                # add category
                category_choice = new_category()
                if category_choice:
                    handling_products(category_choice)
                else:
                    print("Category Already Exists!! Try Another")
                    continue
            elif choice in "bB":
                return
            else:
                print("Type only one character. Try Again!!!")
                continue
        else:
            print("Wrong Choice. Please Try again")
            continue
    return
示例#2
0
文件: customer.py 项目: slk007/MyCart
def category_interaction():

    while True:
        # view category list
        cat_present = Category.get_all_categories()

        if cat_present:

            print("Select any Category from the above list ?")
            tb = PrettyTable(["Category Menu", "Type"])
            tb.add_row(["Yes", "y/Y"])
            tb.add_row(["No", "n/N"])
            print(tb)

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

            if want_cat in "yY":
                # select category
                print("Type Category You Want to Select:")
                print("-" * 30)
                category_choice = input("Your Choice : ")
                print("-" * 30)

                if not db_obj.ref_category.order_by_child(
                        'category_name').equal_to(category_choice).get():
                    print("No such category exits !!!! Try Again")
                    continue

            elif want_cat in "nN":
                # go back to user menu
                return
            else:
                print("Type one character only!! Try Again")
                print("-" * 30)
                continue

            # product
            product_interaction(category_choice)

        else:
            return

    return
order1 = Order(cust1, item1)
order2 = Order(cust1, item2)
order3 = Order(cust2, item4)

print cust1
print cust2

order2.add_item(item5)
order3.add_item(item2)
order3.add_item(item3)

print order3
order3.remove_item(item3)
print order3

print Category.get_all_categories()
print Item.get_all_items()
print categ1
print categ2
item3.change_category(categ1)
print categ1
print categ2
print categ3
categ3.remove(item6)
print categ3
cust2.add_order(item1)
print cust2
print item1
print Order.get_all_orders()