예제 #1
0
def show_whole_items():
    while True:
        registers = register.data.select()[:]
        Console.print_banner(
            Console.green("Product Name")
        )
        Console.print_name_item(registers)
        Console.options_whole_items()
        user_input = input("> ").lower()
        if user_input == "back":
            return False
        validate_to_show_item(user_input, len(registers))
예제 #2
0
def view_item():
    """ View a single product's inventory"""
    is_looking = True
    while is_looking:
        items = len(register.data)
        Console.print_banner("V I E W   I T E M S", "~")
        Console.options_view(items)
        user_input = input("> ").lower()
        if user_input == 'back':
            is_looking = False
            continue
        if user_input == "show":
            is_looking = show_whole_items()
            continue
        validate_to_show_item(user_input, items)
예제 #3
0
def view_item():
    """ View a single product's inventory"""
    is_looking = True
    while is_looking:
        items = len(register.data)
        Console.print_banner("V I E W   I T E M S", "~")
        Console.options_view(items)
        user_input = input("> ").lower()
        if user_input == 'back':
            is_looking = False
            continue
        if user_input == "show":
            is_looking = show_whole_items()
            continue
        validate_to_show_item(user_input, items)
예제 #4
0
def prompt_menu():
    actions = OrderedDict([
        ('v', view_item),
        ('a', add_entry),
        ('b', make_backup),
        ('q', quit_menu)
    ])
    quit_ = False
    while not quit_:
        Console.print_banner("M E N U", '<>')
        Console.print_menu(actions)
        answer = input("> ").lower()
        if answer in actions:
            quit_ = actions[answer]()
            continue
        Console.notification("input", "not correct")       
예제 #5
0
def add_entry():
    """ Add a new product to database """
    item = {}
    for field_key in register.fileds:
        Console.print_banner("A D D   E N T R Y", "~")
        Console.print_field_added(item)
        if field_key == "date_updated":
            continue
        if field_key == "product_price":
            Console.field_key_note()
        item[field_key] = wait_valid_input(field_key)
    try:
        register.fill_records([item])
    except ValueError:
        Console.notification("product", "not added")
    else:
        Console.notification("product", "added successfully")
예제 #6
0
def add_entry():
    """ Add a new product to database """
    item = {}
    for field_key in register.fileds:
        Console.print_banner("A D D   E N T R Y", "~")
        Console.print_field_added(item)
        if field_key == "date_updated":
            continue
        if field_key == "product_price":
            Console.field_key_note()
        item[field_key] = wait_valid_input(field_key)
    try:
        register.fill_records([item])
    except ValueError:
        Console.notification("product", "not added")
    else:
        Console.notification("product", "added successfully")