def menu():
    while True:

        print("""
        Press [1] to Create a Category          Press [2] to View Categories       
        Press [3] to Update Categories          Press [4] to Read Category Data
        Press [5] to Delete Category Data       Press [Q] to close APP
        
        """)

        cmd = input('Please Select an Option!: \n')
        cmd = cmd.lower().strip()

        if cmd == '1':
            category.create_category()

        elif cmd == '2':
            category.view_category()

        elif cmd == '3':
            category.update_file()

        elif cmd == '4':
            category.read_file()

        elif cmd == '5':
            category.delete_data()

        elif cmd == 'q':
            print('Closing APP....')
            break
示例#2
0
    def test_create_category_duplicate(self):
        """Makes sure categories can't be created with the same name and category id."""
        create_category(category_id="001", description="testing")
        from peewee import IntegrityError

        with self.assertRaises(IntegrityError):
            create_category(category_id="001", description="testing")
        Category.get(Category.category_id == "001").delete_instance()
示例#3
0
 def test_create_category(self):
     """Create a category."""
     create_category(category_id="001", description="testing category")
     c = Category.select().where(Category.category_id == "001")
     Category.get(Category.category_id == "001").delete_instance()
     self.assertEqual(
         c,
         "<class 'models.Category'> SELECT `t1`.`id`, "
         "`t1`.`category_id`, `t1`.`description` "
         "FROM `category` AS t1 WHERE (`t1`.`category_id` = %s) ['001']",
     )
示例#4
0
def menuDiplayClient(email):
    print("+--------------MENU---------------------+")
    print("|Chon THH de tao hang hoa               |")
    print("|Chon XHH de xem hang hoa trong kho     |")
    print("|Chon TLH de tao loai hang hoa          |")
    print("|Chon XLH de xem loai hang hoa          |")
    print("|Chon NHH de nhap hang hoa moi vao kho  |")
    print("|Chon XPH de xem phieu nhap hang        |")
    print("|Chon HHB de xem danh sach hang da ban  |")
    print("|Chon C de tao hoa don                  |")
    print("|Chon R de xem thong tin hoa don        |")
    print("|Chon T de tinh tong doanh thu          |")
    print("|Chon A de tinh tong hang hoa ban ra    |")
    print("|Chon E de thoat                        |")
    print("+---------------------------------------+")
    print(email)

    products.load_products()
    category.load_category()

    while True:
        x = input("=> chon chuc nang:")
        print("=> ban da chon chuc nang:", x)
        if x.upper() == 'TLH':
            category.create_category()
        if x.upper() == 'XLH':
            category.danhsach_loaihanghoa()
        if x.upper() == 'THH':
            products.create_products()
        if x.upper() == 'XHH':
            products.danhsach_hanghoa()
        if x.upper() == 'NHH':
            phieunhapkho.create_phieuNhapKho(email)
        if x.upper() == 'XPH':
            phieunhapkho.view_phieu()
        if x.upper() == 'HHB':
            invoice.danhsach_hanghoaban()
        if x.upper() == 'C':
            invoice.create_invoice()
        if x.upper() == 'R':
            invoice.view_invoice()
        if x.upper() == 'T':
            base.top_revenue()
        if x.upper() == 'A':
            base.top_sale_products()
        if x.upper() == 'E':
            print("Tam biet! Hen gap lai")
            break
示例#5
0
 def test_create_category_no_arguments(self):
     """Attempt to create category, but fail if not nullable arguments are missing."""
     with self.assertRaises(TypeError):
         create_category()
from oauth2client.client import flow_from_clientsecrets
from oauth2client.client import FlowExchangeError

import httplib2
import json
import requests

with open('/var/www/catalog/sports-catalog/client_secret.json', 'r') as ci:
    CLIENT_ID = json.loads(ci.read())['web']['client_id']

APPLICATION_NAME = 'Catalog Application'
app = Flask(__name__)
app.secret_key = 'mysecretkey'
engine = db_connect()
Base = create_base(engine)
Category = create_category(Base)
Category_items = create_category_items(Base)
User_info = create_user(Base)
Session = sessionmaker(bind=engine)
session = Session()


# get user info using user email
def getUserId(email):
    try:
        user = session.query(User_info).filter(User_info.email == email).one()
        return user.id
    except:
        return None