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 """ # your code menu_inventory = [ "Print inventory list", "Add to inventory list", "Remove form inventory list", "Update record in inventory list", "Available items", "Average durability" ] title = ["ID", "Name", "Manufacturer", "Purchase_year", "Durability"] title_del = ["Input ID: "] choice = None while choice != "0": choice = terminal_view.get_choice(menu_inventory) if choice == "1": terminal_view.print_table(inventory.get_data(), title) if choice == "2": inventory.new_record( common.get_user_inp_record( terminal_view.get_inputs(title[1:], "")), "model/inventory/inventory.csv") if choice == "3": inventory.delete_record( inventory.get_data(), common.get_user_inp_record( terminal_view.get_inputs(title_del, "")), "model/inventory/inventory.csv") if choice == "4": inventory.update_record( inventory.get_data(), common.get_user_inp_record( terminal_view.get_inputs(title_del, "")), terminal_view.get_inputs(title[1:], ""), "model/inventory/inventory.csv") if choice == "5": terminal_view.print_result( str(inventory.get_available_items(inventory.get_data())), "Available items: ") if choice == "6": terminal_view.print_result( str( inventory.get_average_durability_by_manufacturers( inventory.get_data())), "Oldest persons: ")
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 """ table_headers = ['ID', 'Title', 'Price', 'Month', 'Day', 'Year'] choice = None filename = 'model/sales/sales.csv' columns_headers = ['Title', 'Price', 'Month', 'Day', 'Year'] ask_information = "Please provide your personal information" while choice != "0": choice = terminal_view.get_submenu_choice([ 'Add', 'Remove', 'Update', 'Check lowest price item', 'Check items sold between dates' ]) table = common.get_table_from_file(filename) if choice[0] == "1": common.adding(table, table_headers, filename, columns_headers, ask_information) elif choice[0] == "2": common.removing(table, table_headers, id, filename) elif choice == "3": common.updating(table, table_headers, id, filename, columns_headers, ask_information) elif choice == "4": terminal_view.print_table(table, table_headers) sales_id = sales.get_lowest_price_item_id(table) terminal_view.print_result("The lowest price item id is:", sales_id) elif choice == "5": terminal_view.print_table(table, table_headers) date_list = terminal_view.get_inputs([ 'month_from', 'day_from', 'year_from', 'month_to', 'day_to', 'year_to' ], "Please provide dates information: ") sold_list = sales.get_items_sold_between(table, int(date_list[0]), int(date_list[1]), int(date_list[2]), int(date_list[3]), int(date_list[4]), int(date_list[5])) terminal_view.print_result( "The items sold between given dates are:", sold_list) else: terminal_view.print_error_message("There is no such choice.")
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 """ table_headers = ['ID', 'Name', 'Birth Year'] choice = None filename = 'model/hr/persons.csv' columns_headers = ['Name', 'Birth Year'] ask_information = "Please provide your personal information" common.print_art(0) while choice != "0": choice = terminal_view.get_submenu_choice([ 'Add', 'Remove', 'Update', 'Get oldest person', 'People closest to average age' ]) table = common.get_table_from_file(filename) if choice[0] == "1": common.clear_terminal() common.adding(table, table_headers, filename, columns_headers, ask_information) elif choice[0] == "2": common.clear_terminal() common.removing(table, table_headers, id, filename) elif choice == "3": common.clear_terminal() common.updating(table, table_headers, id, filename, columns_headers, ask_information) elif choice == "4": common.clear_terminal() terminal_view.print_table(table, table_headers) hr_result = hr.get_oldest_person(table) terminal_view.print_result("\nThe oldest people are/ person is", hr_result) elif choice == "5": common.clear_terminal() terminal_view.print_table(table, table_headers) closest_to_average_people = hr.get_persons_closest_to_average( table) terminal_view.print_result("People closest to average age: ", closest_to_average_people) elif int(choice) >= 6: common.clear_terminal() terminal_view.print_error_message("There is no such choice.")
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 item', 'Edit item', 'Remove item', 'Which items have not exceeded their durability yet', 'What are the average durability times for each manufacturer' ] link_to_csv = 'model/inventory/inventory.csv' common_options = [ 'Name of item: ', 'Manufacturer: ', 'Year of purchase: ', 'Years it can be used: ' ] title_list = [ "Id", "Name", "Manufacturer", "Year of purchase", "Years it can be used" ] choice = None dont_clear = False while choice != "0": if not dont_clear: os.system("clear") table = data_manager.get_table_from_file(link_to_csv) terminal_view.print_table(table, title_list) choice = terminal_view.get_choice_submenu(options) dont_clear = False if choice == "1": common.add(link_to_csv, common_options) elif choice == "2": common.update(link_to_csv, common_options) elif choice == "3": common.remove(link_to_csv) elif choice == "4": os.system("clear") table_to_print = inventory.get_available_items(table) terminal_view.print_table(table_to_print, labels) dont_clear = True elif choice == "5": terminal_view.print_result( inventory.get_average_durability_by_manufacturers(table), '\nWhat are the average durability times for each manufacturer: ' ) dont_clear = True else: terminal_view.print_error_message("There is no such choice.")
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 """ # your code menu_hr = [ "Print hr list", "Add to hr list", "Remove form hr list", "Update record in hr list", "Oldest employe", "Average age" ] title = ["Id", "Name", "Year"] title_del = ["Input ID: "] choice = None while choice != "0": choice = terminal_view.get_choice(menu_hr) if choice == "1": terminal_view.print_table(hr.get_data(), title) if choice == "2": hr.new_record( common.get_user_inp_record( terminal_view.get_inputs(title[1:], "")), "model/hr/persons.csv") if choice == "3": hr.delete_record( hr.get_data(), common.get_user_inp_record( terminal_view.get_inputs(title_del, "")), "model/hr/persons.csv") if choice == "4": hr.update_record( hr.get_data(), common.get_user_inp_record( terminal_view.get_inputs(title_del, "")), terminal_view.get_inputs(title[1:], ""), "model/hr/persons.csv") if choice == "5": terminal_view.print_result( str(hr.get_oldest_person(hr.get_data())), "Oldest persons: ") if choice == "6": terminal_view.print_result( str(hr.get_persons_closest_to_average(hr.get_data())), "Closest to average age: ")
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 """ table_headers = ['ID', 'Title', 'Manufacturer', 'Price', 'In Stock'] choice = None filename = 'model/store/games.csv' columns_headers = ['Title', 'Manufacturer', 'Price', 'In Stock'] ask_information = "Please provide your personal information" common.print_art(0) while choice != "0": choice = terminal_view.get_submenu_choice(['Add', 'Remove', 'Update',\ 'How many different kinds of game are available of each manufacturer?',\ 'What is the average amount of games in stock of a given manufacturer?']) table = common.get_table_from_file(filename) if choice[0] == "1": common.clear_terminal() common.adding(table, table_headers, filename, columns_headers, ask_information) elif choice[0] == "2": common.clear_terminal() common.removing(table, table_headers, id, filename) elif choice == "3": common.clear_terminal() common.updating(table, table_headers, id, filename, columns_headers, ask_information) elif choice == "4": common.clear_terminal() terminal_view.print_table(table, table_headers) games_count = store.get_counts_by_manufacturers(table) terminal_view.print_result('Manufacturer', games_count) elif choice == "5": common.clear_terminal() terminal_view.print_table(table, table_headers) manufacturer = terminal_view.get_inputs(['Manufacturer'], 'Which manufacturer?') games_average = store.get_average_by_manufacturer( table, manufacturer[0]) terminal_view.print_result('Avarage amount in stock: ', games_average) elif int(choice) >= 6: common.clear_terminal() terminal_view.print_error_message("There is no such choice.")
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 = [ 'Sales', 'Show all data', 'Add', 'Remove', 'Update', 'Get lowest price item id', 'Get items sold between', 'Exit to main menu' ] data_file = "model/sales/sales.csv" crud_module = sales while True: table = data_manager.get_table_from_file(data_file) max_id = len(table) list_labels = [['Title', str], ['Price', int], ['Month', 'month'], ['Day', 'day'], ['Year', 'year'], ['Customer', 'customer']] user_choice = terminal_view.get_choice(list_options) if user_choice in ['1', '2', '3', '4']: make_crud(crud_module, list_labels, list_options, max_id, table, user_choice) elif user_choice == '5': result = sales.get_lowest_price_item_id(table) terminal_view.print_result(result, "Lowest price item ID") elif user_choice == '6': inputs_labels_between = [ ['Date from', 'date'], ['Date to', 'date'], ] inputs = terminal_view.get_inputs(['must'] + inputs_labels_between, 'Date from to') inputs = [int(item) for item in inputs] result = sales.get_items_sold_between(table, *inputs) print(common.bcolors.WARNING + common.bcolors.BOLD) terminal_view.os.system('clear') if common.check_if_empty(result): terminal_view.print_table(result, list_labels) print(common.bcolors.ENDC) elif user_choice == '0': break else: terminal_view.print_error_message("There is no such choice.")
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 """ table_headers = ['ID', 'Month', 'Day', 'Year', 'Type', 'Amount'] choice = None filename = 'model/accounting/items.csv' columns_headers = ['Month', 'Day', 'Year', 'Type', 'Amount'] ask_information = "Please provide your personal information" common.print_art(0) while choice != "0": choice = terminal_view.get_submenu_choice(['Add', 'Remove', 'Update', 'Which year has the highest profit?',\ 'What is the average (per item) profit in a given year?']) table = common.get_table_from_file(filename) if choice[0] == "1": common.clear_terminal() common.adding(table, table_headers, filename, columns_headers, ask_information) elif choice[0] == "2": common.clear_terminal() common.removing(table, table_headers, id, filename) elif choice == "3": common.clear_terminal() common.updating(table, table_headers, id, filename, columns_headers, ask_information) elif choice == "4": common.clear_terminal() terminal_view.print_table(table, table_headers) accounting_result = accounting.which_year_max(table) terminal_view.print_result("The year with the highest profit is: ", accounting_result) elif choice == "5": common.clear_terminal() terminal_view.print_table(table, table_headers) year = terminal_view.get_inputs(['Year'], 'Which year?') result = accounting.avg_amount(table, int(year[0])) terminal_view.print_result( 'The average profit (per item) in a given year is/are: ', result) elif int(choice) >= 6: common.clear_terminal() terminal_view.print_error_message("There is no such choice.")
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 """ menu_controller = [ "Print controller list", "Add to controller list", "Remove form controller list", "Update record in controller list", "Show subscribers", "Show longest name ID" ] title = ["ID", "Name", "E-mail", "Subscribed"] title_del = ["Input ID: "] choice = None while choice != "0": choice = terminal_view.get_choice(menu_controller) if choice == "1": terminal_view.print_table(crm.get_data(), title) if choice == "2": crm.new_record( common.get_user_inp_record( terminal_view.get_inputs(title[1:], "")), "model/crm/customers.csv") if choice == "3": crm.delete_record( crm.get_data(), common.get_user_inp_record( terminal_view.get_inputs(title_del, "")), "model/crm/customers.csv") if choice == "4": crm.update_record( crm.get_data(), common.get_user_inp_record( terminal_view.get_inputs(title_del, "")), terminal_view.get_inputs(title[1:], ""), "model/crm/customers.csv") if choice == "5": terminal_view.print_result( crm.get_subscribed_emails(crm.get_data()), "Subscribers") if choice == "6": terminal_view.print_result(crm.get_longest_name_id(crm.get_data()), "Longest name ID")
def run(): options = [ "Print list", "Add record", "Update record", "Remove record", 'Transaction by employee', 'Transaction by customer' ] choice = None while choice != "0": choice = terminal_view.get_choice('SALES MENU', options) if choice == "1": # show list of all records terminal_view.print_table(sales_list, 'Sales list') elif choice == "2": # add record crm.create( sales_list, terminal_view.get_inputs(list_labels, 'Enter transaction data below:', ''), sales_file) elif choice == "3": # update record crm.update( sales_list, terminal_view.get_inputs(temp, 'Enter transaction ID to update: ', ''), terminal_view.get_inputs(list_labels[1:], 'Enter id, name or e-mail to update', sales_file), sales_file) elif choice == "4": # remove record crm.delete( sales_list, terminal_view.get_inputs(temp, 'Enter transaction ID to remove: ', ''), sales_file) elif choice == '5': terminal_view.print_result( crm.read(sales_list, terminal_view.get_inputs(temp, 'ID:', '')), '') elif choice == '6': terminal_view.print_result( crm.read(sales_list, terminal_view.get_inputs(temp, 'ID:', '')), '') crm.delete( sales_list, terminal_view.get_inputs(temp, 'Enter transaction ID to remove: ', ''), sales_file) else: terminal_view.print_error_message("There is no such choice.")
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_of_inventory = inventory.get_data_to_list() # your code options = ["Add new record", "Remove a record", "Update record", "Display available items", "Get average durability by manufacturers", "Print Table"] title_list = ["ID", "CONSOLA", "PRODUCENT", "YEAR", "DURABILITY"] choice = None while choice != "0": choice = terminal_view.get_choice(options, "Back to main menu") if choice == "1": new_record = terminal_view.get_inputs(["Name: ", "Manufacturer: ", "Purchase year: ", "Durability: "], "Please enter value: ") new_record.insert(0, inventory.get_random_id(list_of_inventory)) list_of_inventory = inventory.add(list_of_inventory, new_record) elif choice == "2": id_of_record_to_remove = ask_untill_correct(list_of_inventory) list_of_inventory = inventory.remove(list_of_inventory, common.check_id_by_number(list_of_inventory, int(id_of_record_to_remove))) elif choice == "3": id_of_record_to_update = ask_untill_correct(list_of_inventory) updated_record = terminal_view.get_inputs(["Name: ", "Manufacturer: ", "Purchase year: ", "Durability: "], "Please enter value: ") list_of_inventory = inventory.update(list_of_inventory, common.check_id_by_number(list_of_inventory, int(id_of_record_to_update)), updated_record) elif choice == "4": available_items = inventory.get_available_items(list_of_inventory) terminal_view.print_result(available_items, "Available items") elif choice == "5": average_durability = inventory.get_average_durability_by_manufacturers(list_of_inventory) terminal_view.print_result(average_durability, "Average durability by manufacturers") elif choice == "6": terminal_view.print_table(list_of_inventory, title_list) elif choice == "0": inventory.export_list_to_file(list_of_inventory) else: terminal_view.print_error_message("There is no such choice.")
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 """ table_headers = [ 'ID', 'Name', 'Manufacturer', 'Purchase Year', 'Durability' ] choice = None filename = 'model/inventory/inventory.csv' columns_headers = ['Name', 'Manufacturer', 'Purchase Year', 'Durability'] ask_information = "Please provide your personal information" while choice != "0": choice = terminal_view.get_submenu_choice([ 'Add', 'Remove', 'Update', "Items that have not exceeded their durability yet", "Average durability by manufactirers" ]) table = common.get_table_from_file(filename) if choice[0] == "1": common.adding(table, table_headers, filename, columns_headers, ask_information) elif choice[0] == "2": common.removing(table, table_headers, id, filename) elif choice == "3": common.updating(table, table_headers, id, filename, columns_headers, ask_information) elif choice == "4": terminal_view.print_table(table, table_headers) availible_items = inventory.get_available_items(table) terminal_view.print_result( "Items that have not exceeded their durability yet", availible_items) elif choice == "5": terminal_view.print_table(table, table_headers) average_durability = inventory.get_average_durability_by_manufacturers( table) terminal_view.print_result("Average durability by manufactirers:", average_durability)
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 """ table_headers = ['ID','Name', 'Email', 'Subscribed'] choice = None filename = 'model/crm/customers.csv' columns_headers = ['Name', 'Email', 'Subscribed'] ask_information = "Please provide your personal information" common.print_art(0) while choice != "0": choice = terminal_view.get_submenu_choice(['Add', 'Remove', 'Update',\ 'Longest customer name - id',\ 'Newsletter subscribers']) table = common.get_table_from_file(filename) if choice[0] == "1": common.clear_terminal() common.adding(table, table_headers, filename, columns_headers, ask_information) elif choice[0] == "2": common.clear_terminal() common.removing(table, table_headers, id, filename) elif choice == "3": common.clear_terminal() common.updating(table, table_headers, id, filename, columns_headers, ask_information) elif choice == "4": common.clear_terminal() terminal_view.print_table(table, table_headers) longest_name = crm.get_longest_name_id(table) terminal_view.print_result('Id of customer with the longest name: ', longest_name) elif choice == "5": common.clear_terminal() terminal_view.print_table(table, table_headers) subscribers = crm.get_subscribed_emails(table) terminal_view.print_result('Subscribers: ', subscribers) elif int(choice) >= 6: common.clear_terminal() terminal_view.print_error_message("There is no such choice.")
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 """ table = hr.get_hr_table_from_file() title_list = ["ID", "Name", "BirthYear"] options = [ "View records", "Add record", "Remove record", "Update record", "Which person is the oldest?", "Which person is the closet to average age?" ] choice = None while choice != "0": choice = terminal_view.get_choice_inner_menu(options, "HR manager") if choice == "1": terminal_view.print_table(table, title_list) elif choice == "2": record = terminal_view.get_inputs(title_list[1::], "Please provide new item data") table = hr.add(table, record) elif choice == "3": id_to_delete_table = terminal_view.get_inputs(["ID"], "Item to delete") id_to_delete = id_to_delete_table[0] table = hr.remove(table, id_to_delete) elif choice == "4": records = terminal_view.get_inputs(title_list, "Edit item") record_id = records[0] table = hr.update(table, record_id, records) elif choice == "5": oldest_person = hr.get_oldest_person(table) terminal_view.print_result(oldest_person, "The oldest person: ") elif choice == "6": closest_to_average = hr.get_persons_closest_to_average(table) terminal_view.print_result(closest_to_average, "The closest to average is: ") elif choice != "0": terminal_view.print_error_message("There is no such choice.")
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 = [ 'Customer Relations Management', 'Show all customers', 'Add', 'Remove', 'Update', 'Get ID of the customer with the longest name', 'Get customers subscribed to newsletter', 'Exit to main menu' ] data_file = "model/crm/customers.csv" crud_module = crm while True: table = data_manager.get_table_from_file(data_file) max_id = len(table) list_labels = [ ['Name', 'name'], ['Email', 'email'], ['Subscription', 'subscription'] ] user_choice = terminal_view.get_choice(list_options) if user_choice in ['1', '2', '3', '4']: make_crud(crud_module, list_labels, list_options, max_id, table, user_choice) elif user_choice == '5': result = crm.get_longest_name_id(table) terminal_view.print_result(result, "ID of the customer with the longest name") elif user_choice == '6': result = crm.get_subscribed_emails(table) terminal_view.print_result(result, "Customers subscribed to the newsletter") elif user_choice == '0': break else: terminal_view.print_error_message("There is no such choice.")
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 = [ 'Inventory', 'Show all data', 'Add', 'Remove', 'Update', 'Get available items', 'Get average durability by manufacturers', 'Exit to main menu' ] list_labels = [['Name of console', str], ['Manufacturer', str], ['Purchase year', "year"], ['Durability', "durability"]] data_file = "model/inventory/inventory.csv" crud_module = inventory while True: table = data_manager.get_table_from_file(data_file) max_id = len(table) user_choice = terminal_view.get_choice(list_options) if user_choice in ['1', '2', '3', '4']: make_crud(crud_module, list_labels, list_options, max_id, table, user_choice) elif user_choice == '5': print(bcolors.WARNING + bcolors.BOLD) terminal_view.print_table(inventory.get_available_items(table), list_labels) print(bcolors.ENDC) elif user_choice == '6': terminal_view.print_result( inventory.get_average_durability_by_manufacturers(table), 'Average durability by manufactures') elif user_choice == '0': break else: terminal_view.print_error_message("There is no such choice.")
def choose(): choice = None while choice != "0": choice = handle_menu() if choice == "1": store_controller.run() elif choice == "2": hr_controller.run() elif choice == "3": inventory_controller.run() elif choice == "4": accounting_controller.run() elif choice == "5": sales_controller.run() elif choice == "6": crm_controller.run() elif choice == "7": analyser_controller.run() elif choice == "0": terminal_view.print_result("Goodbye") else: terminal_view.print_error_message("There is no such choice.")
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. """ list_options = [ 'Store', 'Show all data', 'Add', 'Remove', 'Update', 'Get counts by manufacturers', 'Get average by manufacturer', 'Exit to main menu' ] list_labels = [['Title', str], ['Manufacturer', str], ['Price', int], ['In stock', int]] data_file = "model/store/games.csv" crud_module = store while True: table = data_manager.get_table_from_file(data_file) max_id = len(table) user_choice = terminal_view.get_choice(list_options) if user_choice in ['1', '2', '3', '4']: make_crud(crud_module, list_labels, list_options, max_id, table, user_choice) elif user_choice == '5': terminal_view.print_result( store.get_counts_by_manufacturers(table), 'Counts by manufactures') elif user_choice == '6': manufacturer = terminal_view.get_inputs([ ['Manufacturer to get average', str], ], 'Manufacturer') terminal_view.print_result( store.get_average_by_manufacturer(table, *manufacturer), 'Average by {}'.format(*manufacturer)) elif user_choice == '0': break else: terminal_view.print_error_message("There is no such choice.")
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 = [ 'Accounting', 'Show all data', 'Add', 'Remove', 'Update', 'Year with the highest profit', 'Average amount', 'Exit to main menu' ] list_labels = [['Month', 'month'], ['Day', 'day'], ['Year', 'year'], ['Type', 'type'], ['Amount', int]] data_file = "model/accounting/items.csv" crud_module = accounting while True: table = data_manager.get_table_from_file(data_file) max_id = len(table) user_choice = terminal_view.get_choice(list_options) if user_choice in ['1', '2', '3', '4']: make_crud(crud_module, list_labels[:], list_options, max_id, table, user_choice) elif user_choice == '5': terminal_view.print_result(accounting.which_year_max(table), 'Year with the highest income') elif user_choice == '6': year = terminal_view.get_inputs(['must'] + [ ['Year to get average', 'year'], ], '') terminal_view.print_result(accounting.avg_amount(table, year[0]), 'Average') elif user_choice == '0': break else: terminal_view.print_error_message("There is no such choice.")
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", "Remove", "Update", "Oldest person", "Persons closest to average"] common_options = ["Name: ", "Year: "] file = "model/hr/persons.csv" title_list = ["Id", "Name", "Year"] choice = None dont_clear = False while choice != '0': if not dont_clear: os.system("clear") table = data_manager.get_table_from_file(file) terminal_view.print_table(table, title_list) choice = terminal_view.get_choice_submenu(options) dont_clear = False if choice == '1': common.add(file, common_options) elif choice == '2': common.remove(file) elif choice == '3': common.update(file, common_options) elif choice == '4': terminal_view.print_result(hr.get_oldest_person(table), "Oldest persons:\n") dont_clear = True elif choice == '5': msg = "Persons with age closest to average:\n" terminal_view.print_result(hr.get_persons_closest_to_average(table), msg) dont_clear = True else: terminal_view.print_error_message("There is no such choice.")
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 """ table = crm.get_crm_table_from_file() title_list = ["ID", "Name", "E-mail", "Subscribed"] options = [ "View records", "Add record", "Remove record", "Update record", "ID releated with the longest name", "The emails with subscription", "The users without subscription" ] choice = None while choice != "0": choice = terminal_view.get_choice_inner_menu( options, "Customer Relationship Management manager") if choice == "1": terminal_view.print_table(table, title_list) elif choice == "2": record = terminal_view.get_inputs(title_list[1::], "Please provide new item data") table = crm.add(table, record) elif choice == "3": id_to_delete_table = terminal_view.get_inputs(["ID"], "Item to delete") id_to_delete = id_to_delete_table[0] table = crm.remove(table, id_to_delete) elif choice == "4": records = terminal_view.get_inputs(title_list, "Edit item") record_id = records[0] table = crm.update(table, record_id, records) elif choice == "5": longest_name_id = crm.get_longest_name_id(table) terminal_view.print_result(longest_name_id, "The longest name ID: ") elif choice == "6": subscribed_emails = crm.get_subscribed_emails(table) terminal_view.print_result(subscribed_emails, "The subscribed emails: ") elif choice == "7": offer = crm.proposition_subscription(table) terminal_view.print_result(offer, "The users without subscription: ") elif choice != "0": terminal_view.print_error_message("There is no such choice.")
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 """ common.clear() title = 'Custom Relationship Mmanager menu' options = ["Add new record to table", "Remove a record with a given id from the table.", "Updates specified record in the table.", "What is the id of the customer with the longest name?", "Which customers has subscribed to the newsletter?"] exit_message = "Back to main menu" title_list = ["ID", "NAME", "EMAIL", "SUBSCRIBED"] table = crm.data_manager.get_table_from_file('model/crm/customers.csv') choice = None while choice != "0": terminal_view.print_table(table, title_list) choice = terminal_view.get_choice(title, options, exit_message) if choice == "1": record = terminal_view.get_inputs(title_list, 'Please add following informations :', table) updated_table = crm.add(table, record) crm.data_manager.write_table_to_file('model/crm/customers.csv', updated_table) common.exit_prompt() common.clear() elif choice == "2": id_ = terminal_view.get_inputs(['Id'], 'Please give ID to remove :', table) updated_table = crm.remove(table, id_) crm.data_manager.write_table_to_file('model/crm/customers.csv', updated_table) common.exit_prompt() common.clear() elif choice == "3": id_ = terminal_view.get_inputs(['Id'], 'Please give ID of changed line :', table) record = terminal_view.get_inputs(title_list, 'Please add following informations :', table) updated_table = crm.update(table, id_, record) crm.data_manager.write_table_to_file('model/crm/customers.csv', updated_table) common.exit_prompt() common.clear() elif choice == "4": label = "The id of the customer with the longest name is: " result = crm.get_longest_name_id(table) terminal_view.print_result(result, label) common.exit_prompt() common.clear() elif choice == "5": label = "Customers that has been subscribed to the newsletter: " result = crm.get_subscribed_emails(table) terminal_view.print_result(result, label) common.exit_prompt() common.clear() elif choice != 0: terminal_view.print_error_message("There is no such choice.") common.exit_prompt() common.clear()
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 """ common.clear() title = 'Store menu' options = [ "Add new record to table", "Remove a record with a given id from the table.", "Updates specified record in the table.", "How many different kinds of game are available of each manufacturer?", "What is the average amount of games in stock of a given manufacturer?" ] exit_message = "Back to main menu" title_list = ["ID", "TITLE", "MANUFACTURER", "PRICE", "IN STOCK"] table = store.data_manager.get_table_from_file('model/store/games.csv') choice = None while choice != "0": terminal_view.print_table(table, title_list) choice = terminal_view.get_choice(title, options, exit_message) if choice == "1": record = terminal_view.get_inputs( title_list, 'Please add following informations :', table) updated_table = store.add(table, record) store.data_manager.write_table_to_file('model/store/games.csv', updated_table) common.exit_prompt() common.clear() elif choice == "2": id_ = terminal_view.get_inputs(['Id'], 'Please give ID to remove :', table) updated_table = store.remove(table, id_) store.data_manager.write_table_to_file('model/store/games.csv', updated_table) common.exit_prompt() common.clear() elif choice == "3": id_ = terminal_view.get_inputs(['Id'], 'Please give ID of changed line :', table) record = terminal_view.get_inputs( title_list, 'Please add following informations :', table) updated_table = store.update(table, id_, record) store.data_manager.write_table_to_file('model/store/games.csv', updated_table) common.exit_prompt() common.clear() elif choice == "4": label = "The kinds of game that are available of each manufacturer: " result = store.get_counts_by_manufacturers(table) terminal_view.print_result(result, label) common.exit_prompt() common.clear() elif choice == "5": manufacturer = terminal_view.get_inputs( ['Manufacturer : '], 'Please select a manufacturer :') manufacturer = manufacturer[0] result = str(store.get_average_by_manufacturer( table, manufacturer)) label = "The average amount of games in stock of {} ".format( manufacturer) terminal_view.print_result(result, label) common.exit_prompt() common.clear() elif choice != 0: terminal_view.print_error_message("There is no such choice.")
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 """ MAX_YEAR = 2020 list_of_accounting = accounting.get_data_to_list() # your code options = [ "Add new record", "Remove a record", "Update record", "Which year has the highest profit?", "What is the average per item", "Print table" ] title_list = ["ID", "Month", "Day", "Year", "Type", "Amount"] choice = None while choice != "0": choice = terminal_view.get_choice(options, "Back to main menu") if choice == "1": new_record = terminal_view.get_inputs( ["Month: ", "Day: ", "Year: ", "Type: ", "Amount: "], "Please enter value: ") new_record.insert(0, accounting.get_random_id(list_of_accounting)) list_of_accounting = accounting.add(list_of_accounting, new_record) elif choice == "2": id_of_record_to_remove = ask_untill_correct( ["Please insert ID"], len(list_of_accounting)) list_of_accounting = accounting.remove( list_of_accounting, common.check_id_by_number(list_of_accounting, int(id_of_record_to_remove))) elif choice == "3": id_of_record_to_update = ask_untill_correct( ["Please insert ID"], len(list_of_accounting)) updated_record = terminal_view.get_inputs( ["Month: ", "Day: ", "Year: ", "Type: ", "Amount :"], "Please enter value: ") list_of_accounting = accounting.update( list_of_accounting, common.check_id_by_number(list_of_accounting, int(id_of_record_to_update)), updated_record) elif choice == "4": result = accounting.which_year_max(list_of_accounting) terminal_view.print_result(str(result), "Year of the highest profile ") elif choice == "5": year_of_check = ask_untill_correct(["Year of publishing: "], MAX_YEAR) result = accounting.avg_amount(list_of_accounting, year_of_check) terminal_view.print_result(str(result), "Avernage items by year") elif choice == "6": terminal_view.print_table(list_of_accounting, title_list) elif choice == "0": accounting.export_list_to_file(list_of_accounting) else: terminal_view.print_error_message( "There is no such choice.") # your code
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 """ common.clear() title = 'Accounting menu' options = [ "Add new record to table", "Remove a record with a given id from the table.", "Updates specified record in the table.", "Which year has the highest profit? (profit = in - out)", "What is the average (per item) profit in a given year? [(profit)/(items count)]" ] exit_message = "Back to main menu" title_list = ["ID", "MONTH", "DAY", "YEAR", 'TYPE', 'DURABILITY'] table = accounting.data_manager.get_table_from_file( 'model/accounting/items.csv') choice = None while choice != "0": terminal_view.print_table(table, title_list) choice = terminal_view.get_choice(title, options, exit_message) if choice == "1": record = terminal_view.get_inputs( title_list, 'Please add following informations :', table) updated_table = accounting.add(table, record) accounting.data_manager.write_table_to_file( 'model/accounting/items.csv', updated_table) common.exit_prompt() common.clear() elif choice == "2": id_ = terminal_view.get_inputs(['Id'], 'Please give ID to remove :', table) updated_table = accounting.remove(table, id_) accounting.data_manager.write_table_to_file( 'model/accounting/items.csv', updated_table) common.exit_prompt() common.clear() elif choice == "3": id_ = terminal_view.get_inputs(['Id'], 'Please give ID of changed line :', table) record = terminal_view.get_inputs( title_list, 'Please add following informations :', table) updated_table = accounting.update(table, id_, record) accounting.data_manager.write_table_to_file( 'model/accounting/items.csv', updated_table) common.exit_prompt() common.clear() elif choice == "4": label = "Which year has the highest profit?" result = str(accounting.which_year_max(table)) terminal_view.print_result(result, label) common.exit_prompt() common.clear() elif choice == "5": year = terminal_view.get_inputs(['year : '], 'Please give a year :') year = year[0] result = str(accounting.avg_amount(table, year)) label = "the average (per item) profit in {} ".format(year) terminal_view.print_result(result, label) common.exit_prompt() common.clear() elif choice != 0: terminal_view.print_error_message("There is no such choice. ")
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 """ # your code options = [ "View the last buyer name", "View the last buyer ID", "View customer name and money spent", "View customer ID and money spent", "View the most frequent buyer name", "View the most frequent buyer ID" ] title_list = ["id", "customer", "Tittle", "price", "month", "day", "year"] file_name = 'data_analyser/buyers.csv' table = data_manager.get_table_from_file(file_name) terminal_view.print_primitive_logo() terminal_view.print_menu("Choose option:", options, "Back to main menu") choice = None while choice != "0": table = data_manager.get_table_from_file(file_name) choice = terminal_view.get_choice() os.system('clear') terminal_view.print_primitive_logo() if choice == "1": terminal_view.print_result( data_analyser.get_the_last_buyer_name_or_id(table, True)) terminal_view.print_menu("Choose option:", options, "Back to main menu") elif choice == "2": terminal_view.print_result( data_analyser.get_the_last_buyer_name_or_id(table, False)) terminal_view.print_menu("Choose option:", options, "Back to main menu") elif choice == "3": terminal_view.print_result( data_analyser.get_customer_money_spent_id_or_name(table, True)) terminal_view.print_menu("Choose option:", options, "Back to main menu") elif choice == "4": terminal_view.print_result( data_analyser.get_customer_money_spent_id_or_name( table, False)) terminal_view.print_menu("Choose option:", options, "Back to main menu") elif choice == "5": terminal_view.print_result( data_analyser.get_the_most_frequent_buyers_id_or_name( table, True)) terminal_view.print_menu("Choose option:", options, "Back to main menu") elif choice == "6": terminal_view.print_result( data_analyser.get_the_most_frequent_buyers_id_or_name( table, False)) terminal_view.print_menu("Choose option:", options, "Back to main menu")
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 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 = [ 'Data Analyser', 'Get the last buyer\'s name', 'Get the last buyer\'s id', 'Get the buyer\'s name who spent most an the money spent he spent', 'Get the buyer id spent most and the money spent', 'Get the most frequent buyers names', 'Get the most frequent buyers ids', 'Get buyers who did not buy anything', 'Exit to main menu' ] list_labels = [ ['Number', int], ] while True: user_choice = terminal_view.get_choice(list_options) if user_choice == '1': terminal_view.print_result(data_analyser.get_the_last_buyer_name(), 'Last buyer\'s name') elif user_choice == '2': terminal_view.print_result(data_analyser.get_the_last_buyer_id(), 'Last buyer\'s id') elif user_choice == '3': terminal_view.print_result( data_analyser. get_the_buyer_name_spent_most_and_the_money_spent(), 'Person who spent most money and amount of this money') elif user_choice == '4': terminal_view.print_result( data_analyser.get_the_buyer_id_spent_most_and_the_money_spent( ), 'Person\'s id who spent most money and amount of this money') elif user_choice == '5': buyers = terminal_view.get_inputs([ ['Number of buyers', int], ], 'Number') terminal_view.print_result( dict( data_analyser.get_the_most_frequent_buyers_names( int(buyers[0]))), 'Names of most frequent buyers') elif user_choice == '6': buyers_ids = terminal_view.get_inputs([ ['Number of buyers', int], ], 'Number') terminal_view.print_result( dict( data_analyser.get_the_most_frequent_buyers_ids( int(buyers_ids[0]))), 'ID\'s of most frequent buyers') elif user_choice == '7': terminal_view.print_list_result( data_analyser.get_customers_who_did_not_buy_anything(), 'Customers who did not buy anything:') elif user_choice == '0': break else: terminal_view.print_error_message("There is no such choice.")