Exemple #1
0
def user_remove_round(object_list):
    print("Here are all the rounds in our database.")
    end_loop = False
    while not end_loop:
        try:
            global round_id_list
            round_id_list = []
            for obj in object_list:
                round_id_list.append(obj.round_id)
            round_num = input(
                """Enter the round id number of the round you want to remove: """
            )
            if not round_num or round_num.isspace():
                print("You have not entered anything!")
                nav.try_again()
            elif round_num.isnumeric() == False:
                print("Please enter a number only.")
                nav.try_again()
            elif round_num not in round_id_list:
                print("Please enter round id number of an existing round.")
                nav.try_again()
            else:
                for obj in object_list:
                    if obj.round_id == round_num:
                        confirmation = nav.confirm()
                        if confirmation:
                            com.remove_round(obj.owner, round_num)
                        else:
                            print("No changes have been made.")
                        end_loop = True
        except ValueError:
            print("No valid input.")
Exemple #2
0
def user_see_round_history(object_list):
    print("Here are all the rounds in our database.")
    end_loop = False
    while not end_loop:
        try:
            global round_id_list
            round_id_list = []
            for obj in object_list:
                round_id_list.append(obj.round_id)
            round_num = input(
                """Enter the round id number of the round's whose 
history you would like to see: """)
            if not round_num or round_num.isspace():
                print("You have not entered anything!")
                nav.try_again()
            elif round_num.isnumeric() == False:
                print("Please enter a number only.")
                nav.try_again()
            elif round_num not in round_id_list:
                print("Please enter round id number of an existing round.")
                nav.try_again()
            else:
                for obj in object_list:
                    if obj.round_id == round_num:
                        os.system("clear")
                        long_col1 = tab.long_col1_round_history(
                            obj.round_history)
                        long_col2 = tab.long_col2_round_history(
                            obj.round_history)
                        long_col3 = tab.long_col3_round_history(
                            obj.round_history)
                        width = tab.round_history_table_width(
                            f"{obj.owner}\'s round", "Order ID", "Name",
                            "Drink", long_col1, long_col2, long_col3)
                        tab.print_round_history(obj.round_history, width,
                                                f"{obj.owner}\'s round",
                                                "Order ID", "Name", "Drink",
                                                long_col1, long_col2,
                                                long_col3)
                end_loop = True
        except ValueError:
            print("No valid input.")
Exemple #3
0
def round_user_input(people_list):
    end_loop = False
    while not end_loop:
        try:
            os.system("clear")
            global round_id_list
            round_id_list = []
            for my_dict in all_rounds_list:
                round_id_list.append(my_dict["RoundID"])

            round_num = input("Enter a new Round ID number: ")
            #check if num already in all rounds
            if not round_num or round_num.isspace():
                print("You have not entered anything!")
                nav.try_again()
            elif round_num.isnumeric() == False:
                print("Please enter a number only.")
                nav.try_again()
            elif round_num in round_id_list:
                print("Round ID number already has been assigned.")
                nav.try_again()
            else:
                owner = input("Enter Round Owner's name: ").capitalize()
                if not owner or owner.isspace():
                    print("You have entered nothing!")
                    nav.try_again()
                elif any(num in owner for num in "0123456789"):
                    print("No numbers can be included in name.")
                    nav.try_again()
                elif owner not in people_list:
                    print("Only an User can be the owner of a round.")
                    nav.try_again()
                else:
                    #add can only be from user table constraint
                    brewer = input("Enter Brewer's name: ").capitalize()
                    #anyone right now
                    active = input("Enter a round active status, Yes or No: "
                                   ).capitalize()
                    #activation constraint of must be yes or no
                    confirmation = nav.confirm()
                    if confirmation:
                        owner = Round_Handler(round_num, owner, brewer, active)
                        round_dict = {
                            'RoundID': owner.round_id,
                            'Owner': owner.owner,
                            'Brewer': owner.brewer,
                            'ActiveStatus': owner.active_status
                        }
                        all_rounds_list.append(round_dict)
                        print(
                            f"{owner.owner}\'s new round has been successfully created!"
                        )
                    else:
                        print("No changes have been made.")
                        pass
                    end_loop = True
        except ValueError:
            print("No valid input.")
            nav.try_again()
    return all_rounds_list
Exemple #4
0
def user_add_pref(my_list1, my_list2, my_dict):
    """ Appends to the specified dictionary, through user inputs, a chosen element from each list
as a key and value respectively. """
    end_loop = False
    while not end_loop:
        try:
            tab.print_counter_var_table("Preferences", "id_number", "names",
                                        my_list1)
            person_id = num_selection(
                """Here are the available people on our list.
Choose the person whose preference you want to change/add.
Enter their id number please: """)
            if 0 < person_id <= len(my_list1):
                try:
                    name = my_list1[person_id - 1]
                    tab.print_counter_var_table("Available Drink Selection",
                                                "Number", "Drink", my_list2)
                    fav_drink_num = input(
                        f"""Great! What is {name}\'s favourite drink? 
Select only from the available drinks menu. Enter a number: """)
                    if not fav_drink_num or fav_drink_num.isspace():
                        print("You have not entered anything!")
                        try_again()
                    elif fav_drink_num.isnumeric() == True:
                        if 0 < int(fav_drink_num) <= len(my_list2):
                            fav_drink = my_list2[int(fav_drink_num) - 1]
                            print(
                                f"""{fav_drink.capitalize()} will be added as {name.capitalize()}'s favourite drink! """
                            )
                            confirmation = confirm()
                            if confirmation:
                                add_to_dict(my_dict, name, fav_drink)
                            else:
                                print("No changes have been made.")
                                pass
                            end_loop = True
                        else:
                            print("Please enter a valid number.")
                            try_again()
                    else:
                        print(f"Please enter only a number.")
                        try_again()
                except ValueError:
                    print("Not a valid input!")
                    try_again()
            else:
                print("Not a valid id number.")
                try_again()
        except ValueError:
            print("You have not entered a number. Try again.")
            try_again()
    return my_dict
Exemple #5
0
def remove_order_from_round(object_list):
    print("Here are all the rounds in our database.")
    end_loop = False
    while not end_loop:
        try:
            global round_id_list
            round_id_list = []
            for obj in object_list:
                round_id_list.append(obj.round_id)
            round_num = input(
                """Enter the round id number of the round, whose order history
 you would like to see and remove an order from: """)
            if not round_num or round_num.isspace():
                print("You have not entered anything!")
                nav.try_again()
            elif round_num.isnumeric() == False:
                print("Please enter a number only.")
                nav.try_again()
            elif round_num not in round_id_list:
                print("Please enter round id number of an existing round.")
                nav.try_again()
            else:
                for obj in object_list:
                    if obj.round_id == round_num:
                        global order_id_list
                        order_id_list = []
                        for order in obj.round_history:
                            order_id_list.append(order["OrderID"])
                        os.system("clear")
                        long_col1 = tab.long_col1_round_history(
                            obj.round_history)
                        long_col2 = tab.long_col2_round_history(
                            obj.round_history)
                        long_col3 = tab.long_col3_round_history(
                            obj.round_history)
                        width = tab.round_history_table_width(
                            f"{obj.owner}\'s round", "Order ID", "Name",
                            "Drink", long_col1, long_col2, long_col3)
                        tab.print_round_history(obj.round_history, width,
                                                f"{obj.owner}\'s round",
                                                "Order ID", "Name", "Drink",
                                                long_col1, long_col2,
                                                long_col3)
                        order_num = input(
                            "Enter the order id number of the order you want to remove:  "
                        )
                        if not order_num or order_num.isspace():
                            print("You have not entered anything!")
                            nav.try_again()
                        elif order_num.isnumeric() == False:
                            print("Please enter a number only.")
                            nav.try_again()
                        elif order_num not in order_id_list:
                            print(
                                "Please enter order id number of an existing order."
                            )
                            nav.try_again()
                        else:
                            confirmation = nav.confirm()
                            if confirmation:
                                remove_order_from_round_db(
                                    obj.owner, round_num, order_num)
                            else:
                                print("No changes have been made.")
                            end_loop = True
        except ValueError:
            print("No valid input.")
Exemple #6
0
def user_add_order_to_round(object_list, people_list, drinks_list):
    round_id_list = []
    for obj in object_list:
        round_id_list.append(obj.round_id)

    end_loop = False
    while not end_loop:
        round_num = input(
            "Choose whose round would you like to add a new order to. Enter their round id: "
        )
        if not round_num or round_num.isspace():
            print("You have not entered anything!")
            nav.try_again()
        elif round_num.isnumeric() == False:
            print("Enter only a positive whole number.")
            nav.try_again()
        elif round_num not in round_id_list:
            print("Please enter a valid round id number.")
            nav.try_again()
        else:
            end_loop = True
            end_loop3 = False
            os.system("clear")
            owner = ""
            for obj in object_list:
                if obj.round_id == round_num:
                    owner = obj.owner
            print(f"Adding to {owner}\'s round. \n")
            tab.print_table_list("Users", people_list)
            print("Here are all the existing users: ")
            while not end_loop3:
                name = input(
                    "Enter the name of the person adding the order from existing users: "
                ).capitalize()
                if not name or name.isspace():
                    print("You have not entered anything!")
                    nav.try_again()
                elif any(num in name for num in "0123456789"):
                    print("Names can not contain any numbers.")
                    nav.try_again()
                elif name not in people_list:
                    print(
                        "Sorry, only an existing user can add an order to a round."
                    )
                    nav.try_again()
                else:
                    end_loop3 = True
                    end_loop = True
                    end_loop4 = False
                    os.system("clear")
                    for obj in object_list:
                        if obj.round_id == round_num:
                            long_col1 = tab.long_col1_round_history(
                                obj.round_history)
                            long_col2 = tab.long_col2_round_history(
                                obj.round_history)
                            long_col3 = tab.long_col3_round_history(
                                obj.round_history)
                            width = tab.round_history_table_width(
                                f"{obj.owner}\'s round", "Order ID", "Name",
                                "Drink", long_col1, long_col2, long_col3)
                            tab.print_round_history(obj.round_history, width,
                                                    f"{obj.owner}\'s round",
                                                    "Order ID", "Name",
                                                    "Drink", long_col1,
                                                    long_col2, long_col3)
                            print(f"Here is {owner}\'s current round histroy.")
                            tab.print_table_list("Drinks", drinks_list)
                    print("Here are the available drinks.")
                    while not end_loop4:
                        drink = input("Choose a drink to add to the round: "
                                      ).capitalize()
                        if not drink or drink.isspace():
                            print("You have not entered anything!")
                            nav.try_again()
                        elif any(num in drink for num in "0123456789"):
                            print("Drink names can not contain numbers.")
                            nav.try_again()
                        elif drink not in drinks_list:
                            print(
                                "Sorry this drink is not available. Please choose from the available drinks."
                            )
                            nav.try_again()
                        else:
                            end_loop4 = True
                            end_loop3 = True
                            end_loop = True
                            os.system("clear")
                            print(f"Add {drink} order to {owner}\'s round?")
                            confirmation = nav.confirm()
                            if confirmation:
                                for obj in object_list:
                                    if obj.round_id == round_num:
                                        com.add_order_to_round(
                                            round_num, owner, name, drink)
                            else:
                                print("No changes have been made.")
                            end_loop = True
Exemple #7
0
def round_user_input(people_list):
    end_loop = False
    while not end_loop:
        try:
            os.system("clear")
            tab.print_table_list("Users", people_list)
            owner_name = input("Enter Round Owner's name: ").capitalize()
            if not owner_name or owner_name.isspace():
                print("You have entered nothing!")
                nav.try_again()
            elif any(num in owner_name for num in "0123456789"):
                print("No numbers can be included in name.")
                nav.try_again()
            elif owner_name not in people_list:
                print("Only an existing user can be the owner of a round.")
                nav.try_again()
            else:
                end_loop = True
                end_loop2 = False
                brewer_name = input("Enter Brewer's name: ").capitalize()
                if not brewer_name or brewer_name.isspace():
                    print("You have not entered anything!")
                    nav.try_again()
                elif any(num in brewer_name for num in "0123456789"):
                    print("No numbers can be included in name.")
                    nav.try_again()
                else:
                    end_loop2 = True
                    end_loop3 = False
                    active = input("""Enter a round active status.
[1] No or [2] Yes
Please enter a number: """)
                    if not active or active.isspace():
                        print("You have not entered anything!")
                        nav.try_again()
                    elif active.isnumeric() == True:
                        if 0 < int(active) < 3:
                            if int(active) == 1:
                                active = "No"
                            else:
                                active = "Yes"
                            confirmation = nav.confirm()
                            if confirmation:
                                com.add_round(owner_name, brewer_name, active)
                            else:
                                print("No changes have been made.")
                            end_loop3 = True
                        else:
                            print(
                                "You have not entered a valid number. Please enter a number between 1 or 2."
                            )
                            nav.try_again()
                    else:
                        print("Please enter a number only.")
                        nav.try_again()
        except ValueError:
            print("No valid input.")
            nav.try_again()
Exemple #8
0
def user_add_order_to_round(object_list, people_list, drinks_list):
    round_id_list = []
    for obj in object_list:
        round_id_list.append(obj.round_id)

    end_loop = False
    while not end_loop:
        round_num = input(
            "Choose whose round would you like to add a new order to. Enter their round id: "
        )
        if not round_num or round_num.isspace():
            print("You have not entered anything!")
            nav.try_again()
        elif round_num.isnumeric() == False:
            print("Enter only a positive whole number.")
            nav.try_again()
        elif round_num not in round_id_list:
            print("Please enter a valid round id number.")
            nav.try_again()
        else:
            owner = ""
            for obj in object_list:
                if obj.round_id == round_num:
                    owner = obj.owner
                    order_id_list = []
                    for my_order in obj.round_history:
                        order_id_list.append(my_order["OrderID"])
            end_loop = True
            end_loop2 = False
            os.system("clear")
            for obj in object_list:
                if obj.round_id == round_num:
                    long_col1 = long_col1_round_history(obj.round_history)
                    long_col2 = long_col2_round_history(obj.round_history)
                    long_col3 = long_col3_round_history(obj.round_history)
                    width = round_history_table_width(f"{obj.owner}\'s round",
                                                      "Order ID", "Name",
                                                      "Drink", long_col1,
                                                      long_col2, long_col3)
                    print_round_history(obj.round_history, width,
                                        f"{obj.owner}\'s round", "Order ID",
                                        "Name", "Drink", long_col1, long_col2,
                                        long_col3)
            while not end_loop2:
                order_id = input("To add a new order, enter a new order id: ")
                if not order_id or order_id.isspace():
                    print("You have not entered anything!")
                    nav.try_again()
                elif order_id.isnumeric() == False:
                    print("Enter only a positive whole number.")
                    nav.try_again()
                elif int(order_id) < 1:
                    print(
                        "Please choose a positive whole number for order id.")
                    nav.try_again()
                elif isinstance(int(order_id), float) == True:
                    print("Please choose only a whole number for order id.")
                    nav.try_again()
                elif order_id in order_id_list:
                    print(
                        "Order id number already assigned. Please choose another id number."
                    )
                    nav.try_again()
                else:
                    end_loop2 = True
                    end_loop = True
                    end_loop3 = False
                    os.system("clear")
                    tab.print_table_list("Users", people_list)
                    print("Here all the existing users.")
                    while not end_loop3:
                        name = input(
                            "Enter the name of the person adding the order: "
                        ).capitalize()
                        if not name or name.isspace():
                            print("You have not entered anything!")
                            nav.try_again()
                        elif any(num in name for num in "0123456789"):
                            print("Names can not contain any numbers.")
                            nav.try_again()
                        elif name not in people_list:
                            print(
                                "Sorry, only an existing user can add an order to a round."
                            )
                            nav.try_again()
                        else:
                            end_loop3 = True
                            end_loop2 = True
                            end_loop = True
                            end_loop4 = False
                            os.system("clear")
                            tab.print_table_list("Drinks", drinks_list)
                            print(
                                "Here are all the drinks that are available.")
                            while not end_loop4:
                                drink = input(
                                    "Choose a drink to add to the round: "
                                ).capitalize()
                                if not drink or drink.isspace():
                                    print("You have not entered anything!")
                                    nav.try_again()
                                elif any(num in drink for num in "0123456789"):
                                    print(
                                        "Drink names can not contain numbers.")
                                    nav.try_again()
                                elif drink not in drinks_list:
                                    print(
                                        "Sorry this drink is not available. Please choose from the available drinks."
                                    )
                                    nav.try_again()
                                else:
                                    end_loop4 = True
                                    end_loop3 = True
                                    end_loop2 = True
                                    end_loop = True
                                    os.system("clear")
                                    print(
                                        f"Add {drink} order to {owner}\'s round?"
                                    )
                                    confirmation = nav.confirm()
                                    if confirmation:
                                        for obj in object_list:
                                            if obj.round_id == round_num:
                                                #add to orders table so order id created there
                                                obj.add_to_round(
                                                    order_id, name, drink)
                                                print(
                                                    f"The order has been added to {obj.owner}\'s round!"
                                                )
                                    else:
                                        print("No changes have been made.")
                                    end_loop = True