Example #1
0
 def msc_srch():
     nonlocal next_screen, hs_db, cur_screen, mlist_head, mlist_prompt
     query = input("Search Query: ")
     search_body = draw.get_body(next_screen, query, hs_db, cur_screen)
     return [next_screen, mlist_head, search_body, mlist_prompt]
Example #2
0
def draw_list(screen, raw_data, cur_screen, hs_db):
    list_len = len(raw_data)
    next_screen = None

    # ingredient building variable initialization
    create_loop = False

    hop_cr = hscls.Hop()
    yst_cr = hscls.Yeast()
    ferm_cr = hscls.Ferm()
    wat_cr = hscls.Water()
    msc_cr = hscls.Misc()

    # prebuilt headers
    hlist_head = 'Hop Select'
    hadd_head = 'Create Hop'
    ylist_head = 'Yeast Select'
    yadd_head = 'Create Yeast'
    flist_head = 'Fermentable/Adjunct Select'
    fadd_head = 'Create Fermentable/Adjunct'
    wlist_head = 'Water Select'
    wadd_head = 'Create Water'
    mlist_head = 'Misc Select'
    madd_head = 'Create Misc'

    # prebuilt prompts
    add_prompt = 'Select Detail to Edit: '
    hlist_prompt = 'Select Hop: '
    ylist_prompt = 'Select Yeast: '
    flist_prompt = 'Select Fermentable/Adjunct: '
    wlist_prompt = 'Select Water: '
    mlist_prompt = 'Select Misc: '

    # Create ingredient switch functions
    def h_name():
        nonlocal create_loop, hop_cr, screen, add_prompt, hadd_head
        create_loop = True
        hop_cr.get_name()
        misc.cls()
        screen = format_list(hadd_head, hop_cr.body, add_prompt)

    def h_origin():
        nonlocal create_loop, hop_cr, screen, add_prompt, hadd_head
        create_loop = True
        hop_cr.get_origin()
        misc.cls()
        screen = format_list(hadd_head, hop_cr.body, add_prompt)

    def h_type():
        nonlocal create_loop, hop_cr, screen, add_prompt, hadd_head
        create_loop = True
        hop_cr.get_type()
        misc.cls()
        screen = format_list(hadd_head, hop_cr.body, add_prompt)

    def h_alpha():
        nonlocal create_loop, hop_cr, screen, add_prompt, hadd_head
        create_loop = True
        hop_cr.get_alpha()
        misc.cls()
        screen = format_list(hadd_head, hop_cr.body, add_prompt)

    def h_beta():
        nonlocal create_loop, hop_cr, screen, add_prompt, hadd_head
        create_loop = True
        hop_cr.get_beta()
        misc.cls()
        screen = format_list(hadd_head, hop_cr.body, add_prompt)

    def h_price():
        nonlocal create_loop, hop_cr, screen, add_prompt, hadd_head
        create_loop = True
        hop_cr.get_price()
        misc.cls()
        screen = format_list(hadd_head, hop_cr.body, add_prompt)

    def h_qty():
        nonlocal create_loop, hop_cr, screen, add_prompt, hadd_head
        create_loop = True
        hop_cr.get_qty()
        misc.cls()
        screen = format_list(hadd_head, hop_cr.body, add_prompt)

    def h_notes():
        nonlocal create_loop, hop_cr, screen, add_prompt, hadd_head
        create_loop = True
        hop_cr.get_notes()
        misc.cls()
        screen = format_list(hadd_head, hop_cr.body, add_prompt)

    def h_save():
        nonlocal create_loop, hop_cr, screen, hs_db, next_screen, add_prompt
        success = hop_cr.save(hs_db)
        if success[0]:
            create_loop = False
            next_screen = 'hop'
        else:
            create_loop = True
            if success[1] == 'name':
                temp_head = 'Name Required'
            else:
                temp_head = 'Invalid data. Double check alpha, beta, price, and quantity.'
            misc.cls()
            screen = format_list(temp_head, hop_cr.body, add_prompt)

    def y_name():
        nonlocal create_loop, yst_cr, screen, add_prompt, yadd_head
        create_loop = True
        yst_cr.get_name()
        misc.cls()
        screen = format_list(yadd_head, yst_cr.body, add_prompt)

    def y_ar():
        nonlocal create_loop, yst_cr, screen, add_prompt, yadd_head
        create_loop = True
        yst_cr.get_ar()
        misc.cls()
        screen = format_list(yadd_head, yst_cr.body, add_prompt)

    def y_prid():
        nonlocal create_loop, yst_cr, screen, add_prompt, yadd_head
        create_loop = True
        yst_cr.get_pid()
        misc.cls()
        screen = format_list(yadd_head, yst_cr.body, add_prompt)

    def y_lab():
        nonlocal create_loop, yst_cr, screen, add_prompt, yadd_head
        create_loop = True
        yst_cr.get_lab()
        misc.cls()
        screen = format_list(yadd_head, yst_cr.body, add_prompt)

    def y_type():
        nonlocal create_loop, yst_cr, screen, add_prompt, yadd_head
        create_loop = True
        yst_cr.get_type()
        misc.cls()
        screen = format_list(yadd_head, yst_cr.body, add_prompt)

    def y_alc():
        nonlocal create_loop, yst_cr, screen, add_prompt, yadd_head
        create_loop = True
        yst_cr.get_alc()
        misc.cls()
        screen = format_list(yadd_head, yst_cr.body, add_prompt)

    def y_floc():
        nonlocal create_loop, yst_cr, screen, add_prompt, yadd_head
        create_loop = True
        yst_cr.get_floc()
        misc.cls()
        screen = format_list(yadd_head, yst_cr.body, add_prompt)

    def y_minatt():
        nonlocal create_loop, yst_cr, screen, add_prompt, yadd_head
        create_loop = True
        yst_cr.get_minat()
        misc.cls()
        screen = format_list(yadd_head, yst_cr.body, add_prompt)

    def y_maxatt():
        nonlocal create_loop, yst_cr, screen, add_prompt, yadd_head
        create_loop = True
        yst_cr.get_maxat()
        misc.cls()
        screen = format_list(yadd_head, yst_cr.body, add_prompt)

    def y_mintmp():
        nonlocal create_loop, yst_cr, screen, add_prompt, yadd_head
        create_loop = True
        yst_cr.get_mintmp()
        misc.cls()
        screen = format_list(yadd_head, yst_cr.body, add_prompt)

    def y_maxtmp():
        nonlocal create_loop, yst_cr, screen, add_prompt, yadd_head
        create_loop = True
        yst_cr.get_maxtmp()
        misc.cls()
        screen = format_list(yadd_head, yst_cr.body, add_prompt)

    def y_price():
        nonlocal create_loop, yst_cr, screen, add_prompt, yadd_head
        create_loop = True
        yst_cr.get_price()
        misc.cls()
        screen = format_list(yadd_head, yst_cr.body, add_prompt)

    def y_qty():
        nonlocal create_loop, yst_cr, screen, add_prompt, yadd_head
        create_loop = True
        yst_cr.get_qty()
        misc.cls()
        screen = format_list(yadd_head, yst_cr.body, add_prompt)

    def y_notes():
        nonlocal create_loop, yst_cr, screen, add_prompt, yadd_head
        create_loop = True
        yst_cr.get_notes()
        misc.cls()
        screen = format_list(yadd_head, yst_cr.body, add_prompt)

    def y_save():
        nonlocal create_loop, yst_cr, screen, hs_db, next_screen, add_prompt
        success = yst_cr.save(hs_db)
        if success[0]:
            create_loop = False
            next_screen = 'yst'
        else:
            create_loop = True
            if success[1] == 'name':
                temp_head = 'Name Required'
            else:
                temp_head = 'Invalid data. Double check price, and quantity.'
            misc.cls()
            screen = format_list(temp_head, yst_cr.body, add_prompt)

    def f_name():
        nonlocal create_loop, ferm_cr, screen, add_prompt, fadd_head
        create_loop = True
        ferm_cr.get_name()
        misc.cls()
        screen = format_list(fadd_head, ferm_cr.body, add_prompt)

    def f_origin():
        nonlocal create_loop, ferm_cr, screen, add_prompt, fadd_head
        create_loop = True
        ferm_cr.get_origin()
        misc.cls()
        screen = format_list(fadd_head, ferm_cr.body, add_prompt)

    def f_type():
        nonlocal create_loop, ferm_cr, screen, add_prompt, fadd_head
        create_loop = True
        ferm_cr.get_type()
        misc.cls()
        screen = format_list(fadd_head, ferm_cr.body, add_prompt)

    def f_pg():
        nonlocal create_loop, ferm_cr, screen, add_prompt, fadd_head
        create_loop = True
        can_write = ferm_cr.get_grav()
        misc.cls()
        if can_write:
            screen = format_list(fadd_head, ferm_cr.body, add_prompt)
        else:
            screen = format_list('Potential/Specific Gravity Requires a Type',
                                 ferm_cr.body, add_prompt)

    def f_col():
        nonlocal create_loop, ferm_cr, screen, add_prompt, fadd_head
        create_loop = True
        ferm_cr.get_col()
        misc.cls()
        screen = format_list(fadd_head, ferm_cr.body, add_prompt)

    def f_dp():
        nonlocal create_loop, ferm_cr, screen, add_prompt, fadd_head
        create_loop = True
        can_write = ferm_cr.get_dp()
        misc.cls()
        if can_write:
            screen = format_list(fadd_head, ferm_cr.body, add_prompt)
        else:
            screen = format_list(
                'Diastatic Power Requires Type "Base Malt", "Specialty Malt", or "Adjunct"',
                ferm_cr.body, add_prompt)

    def f_pc():
        nonlocal create_loop, ferm_cr, screen, add_prompt, fadd_head
        create_loop = True
        can_write = ferm_cr.get_pc()
        misc.cls()
        if can_write:
            screen = format_list(fadd_head, ferm_cr.body, add_prompt)
        else:
            screen = format_list(
                'Protein Content Requires Type "Base Malt", "Specialty Malt", or "Adjunct"',
                ferm_cr.body, add_prompt)

    def f_price():
        nonlocal create_loop, ferm_cr, screen, add_prompt, fadd_head
        create_loop = True
        ferm_cr.get_price()
        misc.cls()
        screen = format_list(fadd_head, ferm_cr.body, add_prompt)

    def f_qty():
        nonlocal create_loop, ferm_cr, screen, add_prompt, fadd_head
        create_loop = True
        ferm_cr.get_qty()
        misc.cls()
        screen = format_list(fadd_head, ferm_cr.body, add_prompt)

    def f_notes():
        nonlocal create_loop, ferm_cr, screen, add_prompt, fadd_head
        create_loop = True
        ferm_cr.get_notes()
        misc.cls()
        screen = format_list(fadd_head, ferm_cr.body, add_prompt)

    def f_save():
        nonlocal create_loop, ferm_cr, screen, hs_db, next_screen, add_prompt
        success = ferm_cr.save(hs_db)
        if success[0]:
            create_loop = False
            next_screen = 'ferm'
        else:
            create_loop = True
            if success[1] == 'name':
                temp_head = 'Name Required'
            else:
                temp_head = 'Invalid data. Double check potential/specific gravity, colour, diastatic power, protein content, price, and quantity.'
            misc.cls()
            screen = format_list(temp_head, ferm_cr.body, add_prompt)

    def w_name():
        nonlocal create_loop, wat_cr, screen, add_prompt, wadd_head
        create_loop = True
        wat_cr.get_name()
        misc.cls()
        screen = format_list(wadd_head, wat_cr.body, add_prompt)

    def w_ph():
        nonlocal create_loop, wat_cr, screen, add_prompt, wadd_head
        create_loop = True
        wat_cr.get_ph()
        misc.cls()
        screen = format_list(wadd_head, wat_cr.body, add_prompt)

    def w_ca():
        nonlocal create_loop, wat_cr, screen, add_prompt, wadd_head
        create_loop = True
        wat_cr.get_ca()
        misc.cls()
        screen = format_list(wadd_head, wat_cr.body, add_prompt)

    def w_mg():
        nonlocal create_loop, wat_cr, screen, add_prompt, wadd_head
        create_loop = True
        wat_cr.get_mg()
        misc.cls()
        screen = format_list(wadd_head, wat_cr.body, add_prompt)

    def w_na():
        nonlocal create_loop, wat_cr, screen, add_prompt, wadd_head
        create_loop = True
        wat_cr.get_na()
        misc.cls()
        screen = format_list(wadd_head, wat_cr.body, add_prompt)

    def w_so4():
        nonlocal create_loop, wat_cr, screen, add_prompt, wadd_head
        create_loop = True
        wat_cr.get_so4()
        misc.cls()
        screen = format_list(wadd_head, wat_cr.body, add_prompt)

    def w_cl():
        nonlocal create_loop, wat_cr, screen, add_prompt, wadd_head
        create_loop = True
        wat_cr.get_cl()
        misc.cls()
        screen = format_list(wadd_head, wat_cr.body, add_prompt)

    def w_hco3():
        nonlocal create_loop, wat_cr, screen, add_prompt, wadd_head
        create_loop = True
        wat_cr.get_hco3()
        misc.cls()
        screen = format_list(wadd_head, wat_cr.body, add_prompt)

    def w_price():
        nonlocal create_loop, wat_cr, screen, add_prompt, wadd_head
        create_loop = True
        wat_cr.get_price()
        misc.cls()
        screen = format_list(wadd_head, wat_cr.body, add_prompt)

    def w_qty():
        nonlocal create_loop, wat_cr, screen, add_prompt, wadd_head
        create_loop = True
        wat_cr.get_qty()
        misc.cls()
        screen = format_list(wadd_head, wat_cr.body, add_prompt)

    def w_notes():
        nonlocal create_loop, wat_cr, screen, add_prompt, wadd_head
        create_loop = True
        wat_cr.get_notes()
        misc.cls()
        screen = format_list(wadd_head, wat_cr.body, add_prompt)

    def w_save():
        nonlocal create_loop, wat_cr, screen, hs_db, next_screen, add_prompt
        success = wat_cr.save(hs_db)
        if success[0]:
            create_loop = False
            next_screen = 'wat'
        else:
            create_loop = True
            if success[1] == 'name':
                temp_head = 'Name Required'
            else:
                temp_head = 'Invalid data. Double check all values.'
            misc.cls()
            screen = format_list(temp_head, wat_cr.body, add_prompt)

    def m_name():
        nonlocal create_loop, msc_cr, screen, add_prompt, madd_head
        create_loop = True
        msc_cr.get_name()
        misc.cls()
        screen = format_list(madd_head, msc_cr.body, add_prompt)

    def m_unit():
        nonlocal create_loop, msc_cr, screen, add_prompt, madd_head
        create_loop = True
        msc_cr.get_unit()
        misc.cls()
        screen = format_list(madd_head, msc_cr.body, add_prompt)

    def m_type():
        nonlocal create_loop, msc_cr, screen, add_prompt, madd_head
        create_loop = True
        msc_cr.get_type()
        misc.cls()
        screen = format_list(madd_head, msc_cr.body, add_prompt)

    def m_price():
        nonlocal create_loop, msc_cr, screen, add_prompt, madd_head
        create_loop = True
        msc_cr.get_price()
        misc.cls()
        screen = format_list(madd_head, msc_cr.body, add_prompt)

    def m_qty():
        nonlocal create_loop, msc_cr, screen, add_prompt, madd_head
        create_loop = True
        msc_cr.get_qty()
        misc.cls()
        screen = format_list(madd_head, msc_cr.body, add_prompt)

    def m_notes():
        nonlocal create_loop, msc_cr, screen, add_prompt, madd_head
        create_loop = True
        msc_cr.get_notes()
        misc.cls()
        screen = format_list(madd_head, msc_cr.body, add_prompt)

    def m_save():
        nonlocal create_loop, msc_cr, screen, hs_db, next_screen, add_prompt
        success = msc_cr.save(hs_db)
        if success[0]:
            create_loop = False
            next_screen = 'msc'
        else:
            create_loop = True
            if success[1] == 'name':
                temp_head = 'Name Required'
            else:
                temp_head = 'Invalid data. Double check price and quantity.'
            misc.cls()
            screen = format_list(temp_head, msc_cr.body, add_prompt)

    # Update ingredient switch functions
    def h_up():
        nonlocal next_screen, hs_db, raw_data
        misc.cls()
        add_val = input("Additional Quantity: ")
        add_val = Decimal(add_val)
        new_val = add_val + raw_data[7]
        next_screen = raw_data
        db_curs = hs_db.cursor()
        db_curs.execute(
            'UPDATE hops SET hop_qty = {} WHERE hop_id = {}'.format(
                new_val, next_screen[0]))
        hs_db.commit()
        db_curs.close()

    def y_up():
        nonlocal next_screen, hs_db, raw_data
        misc.cls()
        add_val = input("Additional Quantity: ")
        add_val = Decimal(add_val)
        new_val = add_val + raw_data[13]
        next_screen = raw_data
        db_curs = hs_db.cursor()
        db_curs.execute(
            'UPDATE yeast SET yeast_qty = {} WHERE yeast_id = {}'.format(
                new_val, next_screen[0]))
        hs_db.commit()
        db_curs.close()

    def f_up():
        nonlocal next_screen, hs_db, raw_data
        misc.cls()
        add_val = input("Additional Quantity: ")
        add_val = Decimal(add_val)
        new_val = add_val + raw_data[9]
        next_screen = raw_data
        db_curs = hs_db.cursor()
        db_curs.execute(
            'UPDATE fermentables SET ferm_qty = {} WHERE ferm_id = {}'.format(
                new_val, next_screen[0]))
        hs_db.commit()
        db_curs.close()

    def w_up():
        nonlocal next_screen, hs_db, raw_data
        misc.cls()
        add_val = input("Additional Quantity: ")
        add_val = Decimal(add_val)
        new_val = add_val + raw_data[10]
        next_screen = raw_data
        db_curs = hs_db.cursor()
        db_curs.execute(
            'UPDATE water SET water_qty = {} WHERE water_id = {}'.format(
                new_val, next_screen[0]))
        hs_db.commit()
        db_curs.close()

    def m_up():
        nonlocal next_screen, hs_db, raw_data
        misc.cls()
        add_val = input("Additional Quantity: ")
        add_val = Decimal(add_val)
        new_val = add_val + raw_data[5]
        next_screen = raw_data
        db_curs = hs_db.cursor()
        db_curs.execute(
            'UPDATE misc SET misc_qty = {} WHERE misc_id = {}'.format(
                new_val, next_screen[0]))
        hs_db.commit()
        db_curs.close()

    # Delete ingredient switch functions
    def h_del():
        nonlocal next_screen, hs_db, raw_data
        next_screen = 'hop'
        db_curs = hs_db.cursor()
        db_curs.execute('DELETE FROM hops WHERE hop_id = {}'.format(
            raw_data[0]))
        hs_db.commit()
        db_curs.close()

    def y_del():
        nonlocal next_screen, hs_db, raw_data
        next_screen = 'yst'
        db_curs = hs_db.cursor()
        db_curs.execute('DELETE FROM yeast WHERE yeast_id = {}'.format(
            raw_data[0]))
        hs_db.commit()
        db_curs.close()

    def f_del():
        nonlocal next_screen, hs_db, raw_data
        next_screen = 'ferm'
        db_curs = hs_db.cursor()
        db_curs.execute('DELETE FROM fermentables WHERE ferm_id = {}'.format(
            raw_data[0]))
        hs_db.commit()
        db_curs.close()

    def w_del():
        nonlocal next_screen, hs_db, raw_data
        next_screen = 'wat'
        db_curs = hs_db.cursor()
        db_curs.execute('DELETE FROM water WHERE water_id = {}'.format(
            raw_data[0]))
        hs_db.commit()
        db_curs.close()

    def m_del():
        nonlocal next_screen, hs_db, raw_data
        next_screen = 'msc'
        db_curs = hs_db.cursor()
        db_curs.execute('DELETE FROM misc WHERE misc_id = {}'.format(
            raw_data[0]))
        hs_db.commit()
        db_curs.close()

    # Default switch function
    def default():
        nonlocal create_loop
        create_loop = False

    # Menu switch functions
    def main_menu():
        nonlocal next_screen
        main_head = 'Main Menu'
        main_body = [(None, 'Inventory'), (None, 'Recipes'),
                     (None, 'Shopping Lists'), (None, 'Ingredients'),
                     (None, 'Log Out'), (None, 'Exit')]
        main_prompt = 'Select Menu: '
        return [next_screen, main_head, main_body, main_prompt]

    def ing_menu():
        nonlocal next_screen
        ing_head = 'Ingredients'
        ing_body = [(None, 'Hops'), (None, 'Yeast'),
                    (None, 'Fermentables & Adjuncts'), (None, 'Water'),
                    (None, 'Miscellaneous'), (None, 'Main Menu')]
        ing_prompt = 'Filter Ingredients: '
        return [next_screen, ing_head, ing_body, ing_prompt]

    def h_add():
        nonlocal next_screen, hop_cr, hadd_head, add_prompt
        return [next_screen, hadd_head, hop_cr.body, add_prompt]

    def y_add():
        nonlocal next_screen, yst_cr, yadd_head, add_prompt
        return [next_screen, yadd_head, yst_cr.body, add_prompt]

    def f_add():
        nonlocal next_screen, ferm_cr, fadd_head, add_prompt
        return [next_screen, fadd_head, ferm_cr.body, add_prompt]

    def w_add():
        nonlocal next_screen, wat_cr, wadd_head, add_prompt
        return [next_screen, wadd_head, wat_cr.body, add_prompt]

    def m_add():
        nonlocal next_screen, msc_cr, madd_head, add_prompt
        return [next_screen, madd_head, msc_cr.body, add_prompt]

    def ext_func():
        nonlocal next_screen
        return next_screen

    def hop_menu():
        nonlocal next_screen, hs_db, hlist_head, hlist_prompt
        hop_body = draw.get_body(next_screen, 'all', hs_db)
        return [next_screen, hlist_head, hop_body, hlist_prompt]

    def yst_menu():
        nonlocal next_screen, hs_db, ylist_head, ylist_prompt
        yst_body = draw.get_body(next_screen, 'all', hs_db)
        return [next_screen, ylist_head, yst_body, ylist_prompt]

    def ferm_menu():
        nonlocal next_screen, hs_db, flist_head, flist_prompt
        ferm_body = draw.get_body(next_screen, 'all', hs_db)
        return [next_screen, flist_head, ferm_body, flist_prompt]

    def wat_menu():
        nonlocal next_screen, hs_db, wlist_head, wlist_prompt
        wat_body = draw.get_body(next_screen, 'all', hs_db)
        return [next_screen, wlist_head, wat_body, wlist_prompt]

    def msc_menu():
        nonlocal next_screen, hs_db, mlist_head, mlist_prompt
        msc_body = draw.get_body(next_screen, 'all', hs_db)
        return [next_screen, mlist_head, msc_body, mlist_prompt]

    def hop_srch():
        nonlocal next_screen, hs_db, cur_screen, hlist_head, hlist_prompt
        query = input("Search Query: ")
        search_body = draw.get_body(next_screen, query, hs_db, cur_screen)
        return [next_screen, hlist_head, search_body, hlist_prompt]

    def yst_srch():
        nonlocal next_screen, hs_db, cur_screen, ylist_head, ylist_prompt
        query = input("Search Query: ")
        search_body = draw.get_body(next_screen, query, hs_db, cur_screen)
        return [next_screen, ylist_head, search_body, ylist_prompt]

    def ferm_srch():
        nonlocal next_screen, hs_db, cur_screen, flist_head, flist_prompt
        query = input("Search Query: ")
        search_body = draw.get_body(next_screen, query, hs_db, cur_screen)
        return [next_screen, flist_head, search_body, flist_prompt]

    def wat_srch():
        nonlocal next_screen, hs_db, cur_screen, wlist_head, wlist_prompt
        query = input("Search Query: ")
        search_body = draw.get_body(next_screen, query, hs_db, cur_screen)
        return [next_screen, wlist_head, search_body, wlist_prompt]

    def msc_srch():
        nonlocal next_screen, hs_db, cur_screen, mlist_head, mlist_prompt
        query = input("Search Query: ")
        search_body = draw.get_body(next_screen, query, hs_db, cur_screen)
        return [next_screen, mlist_head, search_body, mlist_prompt]

    # ingredient create switcher. Provide next_screen variable
    create_case = {
        'hop_name': h_name,
        'hop_origin': h_origin,
        'hop_type': h_type,
        'hop_alpha': h_alpha,
        'hop_beta': h_beta,
        'hop_price': h_price,
        'hop_qty': h_qty,
        'hop_notes': h_notes,
        'hop_save': h_save,
        'yst_name': y_name,
        'yst_ar': y_ar,
        'yst_prid': y_prid,
        'yst_lab': y_lab,
        'yst_type': y_type,
        'yst_alc': y_alc,
        'yst_floc': y_floc,
        'yst_minatt': y_minatt,
        'yst_maxatt': y_maxatt,
        'yst_mintmp': y_mintmp,
        'yst_maxtmp': y_maxtmp,
        'yst_price': y_price,
        'yst_qty': y_qty,
        'yst_notes': y_notes,
        'yst_save': y_save,
        'ferm_name': f_name,
        'ferm_origin': f_origin,
        'ferm_type': f_type,
        'ferm_pg': f_pg,
        'ferm_col': f_col,
        'ferm_dp': f_dp,
        'ferm_pc': f_pc,
        'ferm_price': f_price,
        'ferm_qty': f_qty,
        'ferm_notes': f_notes,
        'ferm_save': f_save,
        'wat_name': w_name,
        'wat_ph': w_ph,
        'wat_ca': w_ca,
        'wat_mg': w_mg,
        'wat_na': w_na,
        'wat_so4': w_so4,
        'wat_cl': w_cl,
        'wat_hco3': w_hco3,
        'wat_price': w_price,
        'wat_qty': w_qty,
        'wat_notes': w_notes,
        'wat_save': w_save,
        'msc_name': m_name,
        'msc_unit': m_unit,
        'msc_type': m_type,
        'msc_price': m_price,
        'msc_qty': m_qty,
        'msc_notes': m_notes,
        'msc_save': m_save
    }

    modify_case = {
        'hop_del': h_del,
        'hop_update': h_up,
        'yst_del': y_del,
        'yst_update': y_up,
        'ferm_del': f_del,
        'ferm_update': f_up,
        'wat_del': w_del,
        'wat_update': w_up,
        'msc_del': m_del,
        'msc_update': m_up
    }

    menu_case = {
        'main': main_menu,
        'ing': ing_menu,
        'hop_add': h_add,
        'yst_add': y_add,
        'ferm_add': f_add,
        'wat_add': w_add,
        'msc_add': m_add,
        'exit': ext_func,
        'log': ext_func,
        'hop': hop_menu,
        'yst': yst_menu,
        'ferm': ferm_menu,
        'wat': wat_menu,
        'msc': msc_menu,
        'hop_srch': hop_srch,
        'yst_srch': yst_srch,
        'ferm_srch': ferm_srch,
        'wat_srch': wat_srch,
        'msc_srch': msc_srch
    }

    query_case = {
        'hop': 'hop',
        'hop_det': 'hop',
        'hop_srch': 'hop',
        'yst': 'yst',
        'yst_det': 'yst',
        'yst_srch': 'yst',
        'ferm': 'ferm',
        'ferm_det': 'ferm',
        'ferm_srch': 'ferm',
        'wat': 'wat',
        'wat_det': 'wat',
        'wat_srch': 'wat',
        'msc_det': 'msc',
        'msc_srch': 'msc'
    }

    # loop until a valid next screen is selected or through a create screen
    while (next_screen == None) or (create_loop == True):
        # print formatted screen and get user input for next screen
        print(screen, end='')
        option = input()

        # get the next screen from user input
        next_screen = draw.get_next(cur_screen, option, list_len, raw_data,
                                    screen)

        # Switch for adding an ingredient
        if type(next_screen) == str:
            create_case.get(next_screen, default)()
        else:
            default()

    # switch for updating/deleting an ingredient
    if type(next_screen) == str:
        modify_case.get(next_screen, default)()
    else:
        default()

    # return the screen data if next screen doesn't require a db query
    if type(next_screen) == str:
        return menu_case.get(next_screen)()
    # get data if next screen does require a db query
    else:
        srch_table = query_case.get(cur_screen)
        next_det = draw.get_body(cur_screen, next_screen[0], hs_db, srch_table)
        det_head = next_det[1]
        return [
            next_screen, det_head, next_det,
            '1. Return\n2. Add Inventory\n3. Delete\n\nSelect Option: '
        ]
Example #3
0
 def msc_menu():
     nonlocal next_screen, hs_db, mlist_head, mlist_prompt
     msc_body = draw.get_body(next_screen, 'all', hs_db)
     return [next_screen, mlist_head, msc_body, mlist_prompt]
Example #4
0
 def wat_menu():
     nonlocal next_screen, hs_db, wlist_head, wlist_prompt
     wat_body = draw.get_body(next_screen, 'all', hs_db)
     return [next_screen, wlist_head, wat_body, wlist_prompt]
Example #5
0
 def ferm_menu():
     nonlocal next_screen, hs_db, flist_head, flist_prompt
     ferm_body = draw.get_body(next_screen, 'all', hs_db)
     return [next_screen, flist_head, ferm_body, flist_prompt]
Example #6
0
 def yst_menu():
     nonlocal next_screen, hs_db, ylist_head, ylist_prompt
     yst_body = draw.get_body(next_screen, 'all', hs_db)
     return [next_screen, ylist_head, yst_body, ylist_prompt]
Example #7
0
 def hop_menu():
     nonlocal next_screen, hs_db, hlist_head, hlist_prompt
     hop_body = draw.get_body(next_screen, 'all', hs_db)
     return [next_screen, hlist_head, hop_body, hlist_prompt]