Example #1
0
def validate_date_future(date):
    """
    Validate if givan date is in future

    Args:
        date_str: date of event choose by user

    Returns:
        :obj: `date`: date of event choose by user
    """

    # not call enywhere
    if date <= date.today():
        view.print_msg("Date have to be in future!")
    else:
        return date
Example #2
0
def validate_date_format(date_str):
    """
    Validate if givan date is correct

    Args:
        date_str: date of event choose by user

    Returns:
        :obj: `date`: date of event choose by user
    """

    try:
        date = convert_date(date_str)
    except (ValueError, IndexError):
        view.print_msg("Wrong data format!")
    else:
        return date
Example #3
0
def cancel_event():
    """
    Call functions to cancel event
    """

    date = view.get_event_date()

    date = validate_date_format(date)

    if date is not None:
        event_name = view.get_event_name().lower()

        if event_name == "checkpoint":
            events.Checkpoint.del_event(date)

        elif event_name == "private mentoring":
            events.PrivateMentoring.del_event(date)

        else:
            view.print_msg("No such event!")
Example #4
0
def start():

    events.PrivateMentoring.read_events()
    events.Checkpoint.read_events()

    convert_existing_date(events.Event.get_events())
    """
    Contain main logic of controller,
    call functions to perform task chosen by user
    """

    choice = None

    head = "Chose option:"
    options_list = [
        "Book private mentoring", "Book checkpoint", "Show all my events",
        "Cancel event", "Reschedule event"
    ]
    exit_msg = "Exit program"

    while choice != "0":
        view.print_menu(head, options_list, exit_msg)
        choice = view.get_choice()
        if choice == "1":
            book_private_mentoring()
        elif choice == "2":
            book_checkpoint()
        elif choice == "3":
            display_all_evets()
        elif choice == "4":
            cancel_event()
        elif choice == "5":
            reschedule_event()
        elif choice == "0":
            say_goodbye()
        else:
            view.print_msg("Wrong option!")

        events.Checkpoint.save_events()
        events.PrivateMentoring.save_events()
Example #5
0
def choice_preffered_mentor():
    """
    Call functions to diplay manu and choose preferred mentor
    """

    AVAIALBLE_OPTIONS_LIST = ["0", "1", "2", "3", "4", "5"]

    choice = None
    preffered_mentor = None

    head = "Chose option:"
    options_list = [
        "Mateusz Ostafi", "Agnieszka Koszany", "Dominik Starzyk",
        "Mateusz Steliga", "Marcin Izworski"
    ]
    exit_msg = "Exit booking provate mentoring"

    while choice not in AVAIALBLE_OPTIONS_LIST:
        view.print_menu(head, options_list, exit_msg)
        choice = view.get_choice()
        if choice == "1":
            preffered_mentor = "Mateusz Ostafi"
        elif choice == "2":
            preffered_mentor = "Agnieszka Koszany"
        elif choice == "3":
            preffered_mentor = "Dominik Starzyk"
        elif choice == "4":
            preffered_mentor = "Mateusz Steliga"
        elif choice == "5":
            preffered_mentor = "Marcin Izworski"
        elif choice == "0":
            view.print_msg("End of booking")
        else:
            view.print_msg("Wrong option!")

    return preffered_mentor
Example #6
0
def reschedule_event():
    """
    Call functions to change event date
    """

    view.print_msg("Enter old event date")
    date = view.get_event_date()

    view.print_msg("Enter new event date")
    new_date = view.get_event_date()

    date = validate_date_format(date)
    new_date = validate_date_format(new_date)

    if date is not None and new_date is not None:
        event_name = view.get_event_name().lower()
        if event_name == "checkpoint":
            events.Checkpoint.change_date(date, new_date)

        elif event_name == "private mentoring":
            events.PrivateMentoring.change_date(date, new_date)

        else:
            view.print_msg("No such event!")