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 """ title_list = ["* id", "* name", "* email", "* subscribed"] options = [ "Add new record to table", "Remove a record with a given id from the table", "Update specified record in the table", "ID of the customer with the longest name", "Customers that have subscribed to the newsletter", "Print table" ] os.system('clear') file = "model/crm/customers.csv" choice = None while choice != "0": terminal_view.print_menu("What do you want to do:", options, "Back to main menu") choice = terminal_view.get_choice(options) if choice == "1": common.all_add(title_list, file) elif choice == "2": common.all_remove(title_list, file) elif choice == "3": common.all_updates(title_list, file) elif choice == "4": file_name = common.get_input("Choose a file: ") if file_name == "": file_name = file table = common.get_table_from_file(file_name) id_with_longest_name = crm.get_longest_name_id(table) os.system("clear") print("ID of the customer with the longest name: ", id_with_longest_name) common.waiting() os.system("clear") elif choice == "5": file_name = common.get_input("Choose a file: ") if file_name == "": file_name = file table = common.get_table_from_file(file_name) subscribed_mails = crm.get_subscribed_emails(table) os.system("clear") print("Customers that have subscribed to the newsletter: ", subscribed_mails) common.waiting() os.system("clear") elif choice == "6": common.all_print_table(title_list, file) else: if 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 """ title_list = [ "* ID", "* Month of the transaction", "* Day of the transaction", "* Year of the transaction", "* Type", "* Amount in USD" ] options = [ "Add new record to table", "Remove a record with a given id from the table", "Update specified record in the table", "Year of the highest profit", "Average profit in a given year", "Print table" ] os.system('clear') file = "model/accounting/items.csv" choice = None while choice != "0": terminal_view.print_menu("What do you want to do:", options, "Back to main menu") choice = terminal_view.get_choice(options) if choice == "1": common.all_add(title_list, file) elif choice == "2": common.all_remove(title_list, file) elif choice == "3": common.all_updates(title_list, file) elif choice == "4": file_name = common.get_input("Choose a file: ") if file_name == "": file_name = file table = common.get_table_from_file(file_name) year_of_highest_profit = accounting.which_year_max(table) os.system("clear") print("Year of the highest profit:", year_of_highest_profit) common.waiting() os.system("clear") elif choice == "5": file_name = common.get_input("Choose a file: ") if file_name == "": file_name = file table = common.get_table_from_file(file_name) terminal_view.print_table(table, title_list) year = int(common.get_input("Enter year: ")) print(accounting.avg_amount(table, year)) common.waiting() os.system("clear") elif choice == "6": common.all_print_table(title_list, file) else: if choice != "0": terminal_view.print_error_message("There is no such choice.")
def run(): """ Uruchamia ten moduł i wyświetla jego menu. * Użytkownik ma tutaj dostęp do domyślnych funkcji specjalnych. * Użytkownik może wrócić do głównego menu. Zwroty: Żaden """ options = [ "Add new record to table", "Remove a record", "Update a record", "Get oldest person in file", "Get closest person to average year in file", "Print table" ] title_list = ["*id", "person", "year"] os.system('clear') file = "model/hr/persons.csv" choice = None while choice != "0": terminal_view.print_menu("What do you want to do: ", options, "Back to main menu") choice = terminal_view.get_choice(options) if choice == "1": common.all_add(title_list, file) elif choice == "2": common.all_remove(title_list, file) elif choice == "3": common.all_updates(title_list, file) elif choice == "4": file_name = common.get_input("Choose a file: ") if file_name == "": file_name = file table = common.get_table_from_file(file_name) oldest_person = hr.get_oldest_person(table) os.system("clear") print("The oldest persons in the file: ", oldest_person) common.waiting() os.system("clear") elif choice == "5": file_name = common.get_input("Choose a file: ") if file_name == "": file_name = file table = common.get_table_from_file(file_name) closest_to_average = hr.get_persons_closest_to_average(table) os.system("clear") print("Closest person to average year is:", closest_to_average) common.waiting() os.system("clear") elif choice == "6": common.all_print_table(title_list, file) else: if choice != "0": terminal_view.print_error_message("There is no such choice.")
def generate_record(table, columns_headers, ask_information, filename): table = common.get_table_from_file(filename) id = common.generate_random(table) record = terminal_view.get_inputs(columns_headers, ask_information) record.insert(0, id) return 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 """ 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" common.print_art(0) 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.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) sales_id = sales.get_lowest_price_item_id(table) terminal_view.print_result("The lowest price item id is", sales_id) elif choice == "5": common.clear_terminal() 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) 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 """ title_list = ["* id", "* title", "* price", "* month of the sale", "* day of the sale", "* year of the sale", "* id of customer"] options = ["Add new record to table", "Remove a record with a given id from the table", "Update specified record in the table", "ID of the item that was sold for the lowest price", "Items that are sold between two given dates", "Print table"] os.system('clear') file = "model/sales/sales.csv" choice = None while choice != "0": terminal_view.print_menu("What do you want to do:", options, "Back to main menu") choice = terminal_view.get_choice(options) if choice == "1": common.all_add(title_list, file) elif choice == "2": common.all_remove(title_list, file) elif choice == "3": common.all_updates(title_list, file) elif choice == "4": file_name = common.get_input("Choose a file: ") if file_name == "": file_name = file table = common.get_table_from_file(file_name) item_the_lowest_price = sales.get_lowest_price_item_id(table) os.system("clear") print("id of the item that was sold for the lowest price: ", item_the_lowest_price) common.waiting() os.system("clear") elif choice == "5": pass elif choice == "6": common.all_print_table(title_list, file) else: if 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 """ 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" common.print_art(0) 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.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) availible_items = inventory.get_available_items(table) terminal_view.print_result( "Items that have not exceeded their durability yet", availible_items) elif choice == "5": common.clear_terminal() 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) 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_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 """ 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 """ 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 """ 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 """ title_list = [ "* id of item", "* title", "* price", "* month of the sale", "* day of the sale", "* year of the sale", "* customer's id" ] # ! sign with a position is unfinished function but added in options # !8. Show the sale numbers of games for each customer-292 # !11. Show the customer who spent the most and the amount spent-365" # !12. Show the customer's id who spent the most and the amount spent-376" # !13. Show the most frequent buyers-387 # !14. Show the if of the most freuent buyers- options = [ "Print table", "Get game title by id", "Show the most recently sold game", "Get the sum of games' prices by their id", "Get the customer's id by the id of a game", "Show ids of all customers who purchased games", "Show sale ids of all customers", "Show the owner of a recently sold game", "Show the owner's id of a recently sold game", "Show the most frequent buyers", "Show the ids of the most frequent buyers", "Get the customer by id" ] os.system('clear') file = "model/sales/sales.csv" choice = None while choice != "0": os.system('clear') terminal_view.print_predator() terminal_view.print_menu("What do you want to do:", options, "Back to main menu") choice = terminal_view.get_choice(options) if choice == "1": os.system("clear") common.all_print_table(title_list, file) elif choice == "2": os.system("clear") print("Get game title by id\n") file_name = common.get_file() if file_name == "": file_name = file table = common.get_table_from_file(file_name) terminal_view.print_table(table, title_list) identification = common.get_input("Enter the id: ") print(sales.get_title_by_id_from_table(table, identification)) common.waiting() os.system("clear") elif choice == "3": file_name = common.get_file() if file_name == "": file_name = file table = common.get_table_from_file(file_name) most_recently_sold_game = sales.get_item_id_title_sold_last(table) print("The most recently sold game is: ") terminal_view.print_table([most_recently_sold_game], ["* id", "* title"]) common.waiting() os.system("clear") elif choice == "4": os.system("clear") print("Get the sum of games' prices by their id\n") file_name = common.get_file() if file_name == "": file_name = file table = common.get_table_from_file(file_name) terminal_view.print_table(table, title_list) item_ids = [] x = True while x: add_id = common.get_input("Enter the id or 'x' to exit: ") if add_id == "x": x = False item_ids.append(add_id) print(sales.get_the_sum_of_prices_from_table(table, item_ids)) common.waiting() os.system("clear") elif choice == "5": os.system("clear") print("Get the customer's id by the id of a game\n") file_name = common.get_file() if file_name == "": file_name = file table = common.get_table_from_file(file_name) terminal_view.print_table(table, title_list) sale_id = common.get_input("Enter the id of a game: ") print(sales.get_customer_id_by_sale_id_from_table(table, sale_id)) common.waiting() os.system("clear") elif choice == "6": file_name = common.get_file() if file_name == "": file_name = file table = common.get_table_from_file(file_name) ids_of_all_customers = sales.get_all_customer_ids_from_table(table) print("ids of all customers who purchased games:\n", ids_of_all_customers) common.waiting() os.system("clear") elif choice == "7": file_name = common.get_file() if file_name == "": file_name = file table = common.get_table_from_file(file_name) sale_ids_of_all_customers = sales.get_all_sales_ids_for_customer_ids_form_table( table) print("Sale ids of all customers:\n\n", sale_ids_of_all_customers) common.waiting() os.system("clear") elif choice == "8": file_name_sales = common.get_double_file( "Choose a file with sales: ") if file_name_sales == "": file_name_sales = file file_name_customer = common.get_double_file( "Choose a file with customers: ") if file_name_customer == "": file_name_customer = "model/crm/customers.csv" table_from_customers = common.get_table_from_file( file_name_customer) table_from_sales = common.get_table_from_file(file_name_sales) last_buyer = sales.get_the_last_buyer_name(table_from_customers, table_from_sales) print("Owner of a recently sold game: ", last_buyer) common.waiting() os.system("clear") elif choice == "9": file_name = common.get_file() if file_name == "": file_name = file table = common.get_table_from_file(file_name) last_buyer_id = sales.get_the_last_buyer_id(table) print("Owner's id of a recently sold game: ", last_buyer_id) common.waiting() os.system("clear") elif choice == "10": file_name_sales = common.get_double_file( "Choose a file with sales: ") if file_name_sales == "": file_name_sales = file file_name_customer = common.get_double_file( "Choose a file with customers: ") if file_name_customer == "": file_name_customer = "model/crm/customers.csv" table_from_customers = common.get_table_from_file( file_name_customer) table_from_sales = common.get_table_from_file(file_name_sales) the_most_frequent_buyers = sales.get_the_most_frequent_buyers_names( table_from_customers, table_from_sales, num=1) print("The most frequent buyers:\n", the_most_frequent_buyers) common.waiting() os.system("clear") elif choice == "11": file_name = common.get_file() if file_name == "": file_name = file table = common.get_table_from_file(file_name) the_most_frequent_buyers_ids = sales.get_the_most_frequent_buyers_ids( table, num=1) print("ids of the most frequent buyers:\n", the_most_frequent_buyers_ids) common.waiting() os.system("clear") elif choice == "12": os.system("clear") print("Get the customer by id\n") file_name = common.get_file() if file_name == "": file_name = "model/crm/customers.csv" table = common.get_table_from_file(file_name) terminal_view.print_table( table, ["* id", "* name", "* email", "* subscribed"]) identification = common.get_input("Enter the id: ") print(crm.get_name_by_id_from_table(table, identification)) common.waiting() os.system("clear") else: if choice != "0": terminal_view.print_error_message("There is no such choice.\n") common.waiting()
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 new record to table", "Remove a record with a given id from the table", "Update specified record in the table", "Number of different kinds of game that are available of each manufacturer", "Average amount of games in stock of a given manufacturer", "Print table" ] title_list = ["*id", "* title", "* manufacturer", "* price", "* in_stock"] os.system('clear') choice = None while choice != "0": terminal_view.print_menu("What do you want to do:", options, "Back to main menu") choice = terminal_view.get_choice(options) os.system('clear') if choice == "1": # to jest dzialajacy plik model/store/games.csv file_name = common.get_input("Choose a file: ") if file_name == "": file_name = "model/store/games.csv" table = common.get_table_from_file(file_name) terminal_view.print_table(table, title_list) record = terminal_view.get_inputs(title_list, "Enter data: ") table = store.add(table, record) common.write_table_to_file(file_name, table) os.system("clear") terminal_view.gprint('*** Record has been added ***') common.waiting() os.system("clear") elif choice == "2": file_name = common.get_input("Choose a file: ") if file_name == "": file_name = "model/store/games.csv" table = common.get_table_from_file(file_name) terminal_view.print_table(table, title_list) id_ = common.get_input("Get id to removed: ") table = store.remove(table, id_) common.write_table_to_file(file_name, table) os.system("clear") terminal_view.gprint('*** Record has been removed ***') common.waiting() os.system("clear") elif choice == "3": file_name = common.get_input("Choose a file: ") if file_name == "": file_name = "model/store/games.csv" table = common.get_table_from_file(file_name) terminal_view.print_table(table, title_list) id_ = common.get_input("Enter id to update: ") record = terminal_view.get_inputs(title_list, "Enter data: ") table = store.update(table, id_, record) common.write_table_to_file(file_name, table) os.system("clear") terminal_view.gprint('*** Record has been updated ***') common.waiting() os.system("clear") elif choice == "4": file_name = common.get_input("Choose a file: ") if file_name == "": file_name = "model/store/games.csv" table = common.get_table_from_file(file_name) dictionary = store.get_counts_by_manufacturers(table) terminal_view.print_dictionary( "Number of different kinds of game that are" + "available of each manufacturer:", dictionary) common.waiting() os.system("clear") elif choice == "5": file_name = common.get_input("Choose a file: ") if file_name == "": file_name = "model/store/games.csv" table = common.get_table_from_file(file_name) terminal_view.print_table(table, title_list) manufacturer = common.get_input("Enter a manufacturer: ") print(store.get_average_by_manufacturer(table, manufacturer)) common.waiting() os.system("clear") elif choice == "6": file_name = common.get_input("Choose a file: ") if file_name == "": file_name = "model/store/games.csv" table = common.get_table_from_file(file_name) terminal_view.print_table(table, title_list) common.waiting() os.system("clear") else: if 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 """ title_list = [ "* ID", "* Name of item", "* Manufacturer", "* Year of purchase", "* Years it can be used" ] options = [ "Add new record to table", "Remove a record with a given id from the table", "Update specified record in the table", "Items that have not exceeded their durability yet", "Average durability for each manufacturer", "Print table" ] os.system('clear') file = "model/inventory/inventory.csv" choice = None while choice != "0": terminal_view.print_menu("What do you want to do: ", options, "Back to main menu") choice = terminal_view.get_choice(options) if choice == "1": common.all_add(title_list, file) elif choice == "2": common.all_remove(title_list, file) elif choice == "3": common.all_updates(title_list, file) elif choice == "4": file_name = common.get_input("Choose a file: ") if file_name == "": file_name = file table = common.get_table_from_file(file_name) items_with_available_durability = inventory.get_available_items( table) os.system("clear") print("Items that have not exceeded their durability:\n", items_with_available_durability) common.waiting() os.system("clear") elif choice == "5": file_name = common.get_input("Choose a file: ") if file_name == "": file_name = "model/store/games.csv" table = common.get_table_from_file(file_name) average_durability = inventory.get_average_durability_by_manufacturers( table) os.system("clear") print("Average durability times for each manufacturer:\n", average_durability) common.waiting() os.system("clear") elif choice == "6": common.all_print_table(title_list, file) else: if choice != "0": terminal_view.print_error_message("There is no such choice.")