def run(): """ Starts this module and displays its menu. * User can access default special features from here. * User can go back to main menu from here. Returns: None """ list_options = [ "1. Add new record to table", "2. Remove a record with a given id from the table", "3. Update specified record in the table", "4. Which items have not exceeded their durability yet?", "5. What are the average durability times for each manufacturer?" ] program_works = True while program_works: table = inventory.get_table() title_list = [ "ID", "NAME", "MANUFACTURER", "PURCHASE YEAR", "DURABILITY" ] terminal_view.print_table(table, title_list) answer = terminal_view.get_choice(list_options) if answer == "1": record = terminal_view.get_inputs([ "ID: ", "Name: ", "Manufacturer: ", "Purchase year: ", "Durability: " ], "Please provide information: \n") common.add(table, record) inventory.save_table(table) elif answer == "2": id_ = terminal_view.get_input("Please enter id number: ") common.remove(table, id_) inventory.save_table(table) elif answer == "3": id_ = terminal_view.get_input("Please enter id number: ") record = terminal_view.get_inputs([ "Enter ID: ", "Name of item: ", "Manufacturer: ", "Year of purchase", "Durability year" ], "Please provide new information") common.update(table, id_, record) inventory.save_table(table) elif answer == "4": inventory.get_oldest_person(table) elif answer == "5": inventory.get_average_durability_by_manufacturers(table) elif answer == "0": program_works = False else: terminal_view.print_error_message( "There is no such choice. Choose from 1 to 5") return
def run(): """ Starts this module and displays its menu. * User can access default special features from here. * User can go back to main menu from here. Returns: None """ list_options = [ "1. Add new record to table", "2. Remove a record with a given id from the table", "3. Update specified record in the table", "4. Which year has the highest profit?", "5. What is the average (per item) profit in a given year?" ] program_works = True while program_works: table = accounting.get_table() title_list = ["ID", "MONTH", "DAY", "YEAR", "TYPE", "AMOUNT"] terminal_view.print_table(table, title_list) answer = terminal_view.get_choice(list_options) if answer == "1": record = terminal_view.get_inputs([ "ID: ", "Month of the transaction: ", "Day of the transaction: ", "Year of the transaction: ", "Type - income/outflow (in.out): ", "Amount of transaction in USD: " ], "Please provide information: \n") common.add(table, record) accounting.save_table(table) elif answer == "2": id_ = terminal_view.get_input("Please enter id number: ") common.remove(table, id_) accounting.save_table(table) elif answer == "3": id_ = terminal_view.get_input("Please enter id number: ") record = terminal_view.get_inputs( ["ID: ", "Month: ", "Day: ", "Year: ", "Type: ", "Ammount: "], "Please provide new information") common.update(table, id_, record) accounting.save_table(table) elif answer == "4": accounting.which_year_max(table) elif answer == "5": accounting.avg_amount(table, year) elif answer == "0": program_works = False else: terminal_view.print_error_message( "There is no such choice. Choose from 1 to 5") return
def run(): """ Starts this module and displays its menu. * User can access default special features from here. * User can go back to main menu from here. Returns: None """ list_options = [ "1. Add new record to table", "2. Remove a record with a given id from the table", "3. Update specified record in the table", "4. Which person is oldest", "5. Which person is closest to average" ] program_works = True while program_works: table = hr.get_table() title_list = ["ID", "NAME", "DATE OF BIRTH"] terminal_view.print_table(table, title_list) answer = terminal_view.get_choice(list_options) if answer == "1": record = terminal_view.get_inputs( ["ID: ", "Name and surname: ", "Date of birth: "], "Please provide your personal information") common.add(table, record) hr.save_table(table) elif answer == "2": id_ = terminal_view.get_input("Please enter id number: ") common.remove(table, id_) hr.save_table(table) elif answer == "3": id_ = terminal_view.get_input("Please enter id number: ") record = terminal_view.get_inputs( ["ID: ", "Name and surname: ", "Year of birth: "], "Please provide new information") common.update(table, id_, record) hr.save_table(table) elif answer == "4": print(hr.get_oldest_person(table)) # result = hr.get_oldest_person(table) # terminal_view.print_result(result, "Oldest person is: ") elif answer == "5": hr.get_persons_closest_to_average(table) elif answer == "0": program_works = False else: terminal_view.print_error_message( "There is no such choice. Choose from 1 to 5") return
def run(): options = ["Add", "Remove", "Update", "Lowest price item ID", "Items sold between", "Game title by ID", "All the Customer\'s IDs", "The sales of each customer", "The sales of each customer", "The number of sales of each customer", "The number of sales of each customer: "] common_options = ["Title: ", "Price: ", "Month: ", "Day: ", "Year: "] link_for_csv = "model/sales/sales.csv" title_list = ["ID", "Title", "Price", "Month", "Day", "Year", "Customer ID"] choice = None dont_clear = False while choice != '0': if not dont_clear: os.system("clear") table = data_manager.get_table_from_file(link_for_csv) terminal_view.print_table(table, title_list) choice = terminal_view.get_choice_submenu(options) dont_clear = False if choice == '1': common.add(link_for_csv, common_options) elif choice == '2': common.remove(link_for_csv) elif choice == '3': common.update(link_for_csv, common_options) elif choice == '4': lowest_price = sales.get_lowest_price_item_id(table) terminal_view.print_result(lowest_price, 'Lowest price game is: ') dont_clear = True elif choice == '5': dates_to_input = ['From month: ', 'From day: ', 'From year: ', 'To month:', 'To day: ', "To year: "] inputs = terminal_view.get_input(dates_to_input, "Please input appropriate data.") answer = sales.get_items_sold_between(table, int(inputs[0]), int(inputs[1]), int(inputs[2]), int(inputs[3]), int(inputs[4]), int(inputs[5])) terminal_view.print_table(answer, title_list) dont_clear = True elif choice == '6': dates_to_input = 'Input ID: ' inputs = terminal_view.get_input(dates_to_input, 'Please input appropriate data.') answer = sales.get_title_by_id(inputs) terminal_view.print_result(answer, 'Game title is: ') dont_clear = True elif choice == "7": terminal_view.print_result(sales.get_all_customer_ids_from_table(table), 'All the Customer\'s ID: ') dont_clear = True elif choice == "8": terminal_view.print_result(sales.get_all_sales_ids_for_customer_ids(), "The sales of each customer: ") dont_clear = True elif choice == "9": terminal_view.print_result(sales.get_all_sales_ids_for_customer_ids_form_table(table), "The sales of each customer: ") dont_clear = True elif choice == "10": terminal_view.print_result(sales.get_num_of_sales_per_customer_ids(), "The number of sales of each customer: ") dont_clear = True elif choice == "11": terminal_view.print_result(sales.get_num_of_sales_per_customer_ids_from_table(table), "The number of sales of each customer: ") dont_clear = True
def run(): """ Starts this module and displays its menu. * User can access default special features from here. * User can go back to main menu from here. Returns: None """ list_options = ["1. Add new record to table", "2. Remove a record with a given id from the table", "3. Update specified record in the table", "4. How many different kinds of game are available of each manufacturer?", "5. What is the average amount of games in stock of a given manufacturer?"] program_works = True while program_works: table = store.get_table() title_list = ["ID", "TITLE", "MANUFACTURER", "PRICE (in $)", "IN STOCK"] terminal_view.print_table(table, title_list) answer = terminal_view.get_choice(list_options) if answer == "1": record = terminal_view.get_inputs(["ID: ","Title of the game: ","Manufacturer: ","Price in dollars: ","In stock (number): "],"Please provide information: \n") common.add(table, record) store.save_table(table) elif answer == "2": id_ = terminal_view.get_input("Please enter id number: ") common.remove(table, id_) store.save_table(table) elif answer == "3": id_ = terminal_view.get_input("Please enter id number: ") record = terminal_view.get_inputs(["ID: ","Title of the game: ","Manufacturer: ","Price in dollars: ","In stock (number): "],"Please provide information: \n") common.update(table, id_, record) store.save_table(table) elif answer =="4": store.get_counts_by_manufacturers(table) elif answer == "5": store.get_average_by_manufacturer(table, manufacturer) elif answer == "0": program_works = False else: terminal_view.print_error_message("There is no such choice. Choose from 1 to 5") return
def update(file, common_options): get_table_from(file) id_ = terminal_view.get_input("ID: ", "Please provide ID, which you want to edit") record = terminal_view.get_inputs([opt for opt in common_options], "Please provide following data: ") save(file, common.update(get_table_from(file), id_, record))
def run(): """ Starts this module and displays its menu. * User can access default special features from here. * User can go back to main menu from here. Returns: None """ list_options = ["1. Add new record to table", "2. Remove a record with a given id from the table", "3. Update specified record in the table", "4. What is the id of the item that was sold for the lowest price?", "5. Which items are sold between two given dates?"] program_works = True while program_works: table = sales.get_table() title_list = ["ID", "TITLE", "PRICE","MONTH","DAY","YEAR"] terminal_view.print_table(table, title_list) answer = terminal_view.get_choice(list_options) if answer == "1": record = terminal_view.get_inputs(["ID: ","Title of the game sold: ","The actual sale price in USD: ","Month of the sale: ","Day of the sale: ","Year of the sale: "],"Please provide information: \n") common.add(table, record) sales.save_table(table) elif answer == "2": id_ = terminal_view.get_input("Please enter id number: ") common.remove(table, id_) sales.save_table(table) elif answer == "3": id_ = terminal_view.get_input("Please enter id number: ") record = terminal_view.get_inputs(["ID: ","Title of the game sold: ","The actual sale price in USD: ","Month of the sale: ","Day of the sale: ","Year of the sale: "],"Please provide information: \n") common.update(table, id_, record) sales.save_table(table) elif answer == "4": sales.get_oldest_person(table) elif answer == "5": sales.get_items_sold_between(table, month_from, day_from, year_from, month_to, day_to, year_to) elif answer == "0": program_works = False else: terminal_view.print_error_message("There is no such choice. Choose from 1 to 5") return
def input_for_add_menu(): ''' This function exists because test.py reads terminal_view.get_input() as usage of standard input() function. What can you do? ''' return terminal_view.get_input("Crm ID: ", "Please provide existing user ID")
def run(): """ Starts this module and displays its menu. * User can access default special features from here. * User can go back to main menu from here. Returns: None """ options = [ "Add data", "Remove data", "Update data", "The customer ID with the Longest name", "Newsletter subscription", "Customer\'s name with the given ID" ] common_options = [ "Name: ", "E-mail: ", "Newsletter subscribtion ('1'-yes or '0'-no): " ] link_for_csv = "model/crm/customers.csv" title_list = ["ID", "Name", "E-mail", "Newsletter subscribtion"] choice = None dont_clear = False while choice != '0': if not dont_clear: os.system("clear") table = data_manager.get_table_from_file(link_for_csv) terminal_view.print_table(table, title_list) choice = terminal_view.get_choice_submenu(options) dont_clear = False if choice == '1': common.add(link_for_csv, common_options) elif choice == '2': common.remove(link_for_csv) elif choice == '3': common.update(link_for_csv, common_options) elif choice == '4': terminal_view.print_result( crm.get_longest_name_id(table), 'ID of the customer with the Longest name: ') dont_clear = True elif choice == '5': table_subscription = crm.get_subscribed_emails(table) terminal_view.print_result( table_subscription, 'Customers who has subscribed to the newsletter: ') dont_clear = True elif choice == '6': ID = terminal_view.get_input("ID: ", "Please enter ID: ") terminal_view.print_result( crm.get_name_by_id_from_table(table, ID), "Customer\'s name by given ID: ") dont_clear = True else: terminal_view.print_error_message( "There is no such choice, please try again")
def run(): """ Starts this module and displays its menu. * User can access default special features from here. * User can go back to main menu from here. Returns: None """ options = [ "Add data", "Remove data", "Update data", "Year with the highest profit", "The average profit for a given year" ] common_options = [ "Month: ", "Day: ", "Year: ", "Income (enter: 'in') or Outflow(enter:'out') money: ", "Amount: " ] link_for_csv = 'model/accounting/items.csv' title_list = [ "ID", "Month", "Day", "Year", "Income or Outflow money", "Amount" ] choice = None dont_clear = False while choice != "0": if not dont_clear: os.system("clear") table = data_manager.get_table_from_file(link_for_csv) terminal_view.print_table(table, title_list) choice = terminal_view.get_choice_submenu(options) dont_clear = False if choice == "1": common.add(link_for_csv, common_options) elif choice == "2": common.remove(link_for_csv) elif choice == "3": common.update(link_for_csv, common_options) elif choice == "4": terminal_view.print_result(accounting.which_year_max(table), "Year with the highest profit: ") dont_clear = True elif choice == "5": year = int( terminal_view.get_input( "Year: ", "Enter a year to find out an average profit: ")) terminal_view.print_result( accounting.avg_amount(table, year), 'The average profit for a given year: ') dont_clear = True else: terminal_view.print_error_message( "There is no such choice, please try again")
def run(): """ Starts this module and displays its menu. * User can access default special features from here. * User can go back to main menu from here. Returns: None """ list_options = [ "1. Add new record to table", "2. Remove a record with a given id from the table", "3. Update specified record in the table", "4. What is the id of the customer with the longest name?", "5. Which customers has subscribed to the newsletter?" ] program_works = True while program_works: table = crm.get_table() title_list = [ "ID", "NAME", "EMAIL", "SUBSCRIBED? y/n", ] terminal_view.print_table(table, title_list) answer = terminal_view.get_choice(list_options) if answer == "1": record = terminal_view.get_inputs( ["ID: ", "Name: ", "E-mail: ", "Subscription? Yes/ No"], "Please provide information: \n") common.add(table, record) crm.save_table(table) elif answer == "2": id_ = terminal_view.get_input("Please enter id number: ") common.remove(table, id_) crm.save_table(table) elif answer == "3": common.update(table, id_, record) elif answer == "4": crm.get_longest_name_id(table) elif answer == "5": crm.get_subscribed_emails(table) elif answer == "0": program_works = False else: terminal_view.print_error_message( "There is no such choice. Choose from 1 to 5") return
def run(): options = [ "Add", "Remove", "Update", "Lowest price item ID", "Items sold between", "Game title by ID", "All the Customer\'s IDs", "Item that was sold most recently", "The sales of each customer", "The number of sales of each customer", "Sum of prices for given IDs", "Customer ID for Sale ID" ] common_options = ["Title: ", "Price: ", "Month: ", "Day: ", "Year: "] file = "model/sales/sales.csv" title_list = [ "ID", "Title", "Price", "Month", "Day", "Year", "Customer ID" ] choice = None terminal_clear = False while choice != '0': if not terminal_clear: os.system("clear") table = common.clear_instructions(file, title_list) choice = terminal_view.get_choice_submenu(options) terminal_clear = False if choice == '1': sales.add(common_options) elif choice == '2': sales.remove() elif choice == '3': sales.update(common_options) elif choice == '4': lowest_price = sales.get_lowest_price_item_id(table) terminal_view.print_result(lowest_price, 'Lowest price game is: ') terminal_clear = True elif choice == '5': dates_to_input = [ 'From month: ', 'From day: ', 'From year: ', 'To month:', 'To day: ', "To year: " ] inputs = terminal_view.get_input(dates_to_input, "Please input appropriate data.") answer = sales.get_items_sold_between(table, int(inputs[0]), int(inputs[1]), int(inputs[2]), int(inputs[3]), int(inputs[4]), int(inputs[5])) terminal_view.print_table(answer, title_list) terminal_clear = True elif choice == '6': dates_to_input = 'Input ID: ' inputs = terminal_view.get_input(dates_to_input, 'Please input appropriate Id.') answer = sales.get_title_by_id(inputs) terminal_view.print_result(answer + '\n', 'Game title is: \n') terminal_clear = True elif choice == "7": terminal_view.print_result( sales.get_all_customer_ids_from_table(table), 'All the Customer\'s ID: ') terminal_clear = True elif choice == "8": terminal_view.print_result(sales.get_item_id_sold_last(), 'Item that was sold most recently') terminal_clear = True elif choice == "9": terminal_view.print_result( sales.get_all_sales_ids_for_customer_ids_form_table(table), "The sales of each customer: ") terminal_clear = True elif choice == "10": terminal_view.print_result( sales.get_num_of_sales_per_customer_ids_from_table(table), "The number of sales of each customer: ") terminal_clear = True elif choice == "11": ids_amount = terminal_view.get_input( "Amount of IDs: ", "How many IDs would you like to sum up?") ids = [] for i in range(int(ids_amount)): ids.append("Sale ID: ") inputs = terminal_view.get_inputs(ids, "Please provide an ID") result = sales.get_the_sum_of_prices_from_table(table, inputs) terminal_view.print_result(result, "Sum of prices for given IDs: ") terminal_clear = True elif choice == "12": sale_id = terminal_view.get_input("Sale ID: ", "Please provide sale ID") result = sales.get_customer_id_by_sale_id_from_table( table, sale_id) terminal_view.print_result( result, "Customer ID for Sale ID you provided: ") terminal_clear = True else: terminal_view.print_error_message( "There is no such choice, please try again")
def remove(file): get_table_from(file) id_ = terminal_view.get_input( "ID: ", "Please provide ID, which you want to remove") save(file, common.remove(get_table_from(file), id_))
def run(): options = [ "Customer name of the last buyer", "Customer ID of the last buyer", "Customer who spent the most money", "Customer\'s ID who spent the most money", "Buyers, who effected more purchases", "Buyers\' ID, who effected more purchases" ] choice = None terminal_clear = False while choice != '0': if not terminal_clear: os.system("clear") choice = terminal_view.get_choice_submenu(options) terminal_clear = False if choice == '1': last_buyer = data_analyser.get_the_last_buyer_name() terminal_view.print_result(last_buyer, 'Customer name of the last buyer: ') terminal_clear = True elif choice == '2': last_buyer_id = data_analyser.get_the_last_buyer_id() terminal_view.print_result(last_buyer_id, 'Customer ID of the last buyer: ') terminal_clear = True elif choice == '3': customer_most_money = data_analyser.get_the_buyer_name_spent_most_and_the_money_spent( ) terminal_view.print_result(customer_most_money, "Customer who spent the most money: ") terminal_clear = True elif choice == '4': customer_id_most_money = data_analyser.get_the_buyer_id_spent_most_and_the_money_spent( ) terminal_view.print_result( customer_id_most_money, "Customer\'s ID who spent the most money: ") terminal_clear = True elif choice == '5': num = int( terminal_view.get_input( "Number of people: ", "Please enter a number of people, who you want to see, in the list of more purchases: " )) list_buyers_sales = data_analyser.get_the_most_frequent_buyers_names( num) terminal_view.print_result( list_buyers_sales, "Buyers, who effected more purchases: ") terminal_clear = True elif choice == '6': num = int( terminal_view.get_input( "Number of people: ", "Please enter a number of people, who you want to see, in the list of more purchases: " )) list_id_buyers_sales = data_analyser.get_the_most_frequent_buyers_ids( num) terminal_view.print_result( list_id_buyers_sales, "Buyers\' ID, who effected more purchases: ") terminal_clear = True else: terminal_view.print_error_message( "There is no such choice, please try again")