示例#1
0
def new_woman():
    full_name = input('Full name:')
    if not full_name:
        print('You should enter proper name')
        new_woman()
    s_wc_stability = input('Stability 0: stable, 1: unstable (default - stable):')
    if s_wc_stability not in ['0', '1']:
        wc_stability = 0
    else:
        wc_stability = int(s_wc_stability)
    s_wc_cycle = input('Cycle, days (default - 28):')
    try:
        wc_cycle = int(s_wc_cycle)
    except ValueError:
        wc_cycle = 28
    s_wc_last_cycle = input('Last cycle yy-mm-dd (default: today)')
    try:
        wc_last_cycle = datetime.datetime.strptime(s_wc_last_cycle, '%y-%m-%d')
    except ValueError:
        wc_last_cycle = datetime.date.today()

    Woman.create(full_name=full_name, wc_stability=wc_stability, wc_cycle=wc_cycle, wc_last_cycle=wc_last_cycle)
    print('Woman info created! Press key to return.')
    input()
    main_menu()
示例#2
0
def woman_detail():
    woman_id = input('Woman id:')

    try:
        woman = Woman.get(Woman.id == woman_id)
        print('Full name: %s' % woman.full_name)
        print('Stability: %s' % woman.wc_stability)
        print('Cycle: %s' % woman.wc_cycle)
        print('Last cycle: %s' % woman.wc_last_cycle)
        print('Current phase: %s' % get_cycle(woman.wc_last_cycle, datetime.date.today(), woman.wc_cycle))
        print('')
        print('Choose one of the following:')
        print('1. Edit')
        print('2. Delete')
        print('3. Return to list')
        val = input('Choice:')
        if val == '1':
            woman_edit(woman)
        elif val == '2':
            woman_delete(woman)
        elif val == '3':
            women_list()
        else:
            main_menu()

    except Woman.DoesNotExist:
        print('No woman with such id')
        main_menu()
示例#3
0
def women_list():
    q = Woman.select()
    if q.count():
        for woman in q:
            print('%s. Name: %s' % (woman.id, woman.full_name))
    else:
        print('No women info yet. Press key to return')
        input('')
        main_menu()

    print('Choose one of the following:')
    print('1. Detail')
    print('2. New')
    print('3. Return to main menu')

    val = input('Choice:')
    if val == '1':
        woman_detail()
    elif val == '2':
        new_woman()
    else:
        main_menu()