def start_module(): # Prints menu os.system('cls' if os.name == 'nt' else 'clear') file_name = "student.csv" table = data_manager.import_file(file_name) menu = [ "Create student", "Read student", "Read students", "Update students", "Activate / Deactivate a student", "Delete student", "Back to main" ] ui.print_menu(menu) x = int(ui.get_input("Enter a number here: ")) if x == 1: create_student(file_name) if x == 2: student_ID = ui.get_input("Enter a student ID here: ") read_student(student_ID, table) if x == 3: read_students(table) if x == 4: student_ID = ui.get_input("Enter a student ID here: ") update_student(table, student_ID, file_name) if x == 5: student_ID = ui.get_input("Enter a student ID here: ") activate_deactivate_student(table, student_ID, file_name) if x == 6: student_ID = ui.get_input("Enter a student ID here: ") delete_student(table, student_ID, file_name) if x == 7: main.main()
def start_module(): os.system('cls' if os.name == 'nt' else 'clear') file_name = "postion.csv" table = data_manager.import_file(file_name) menu = ["Create position", "Read position", "Read positions", "Update position", "Delete position", "Back to main menu"] ui.print_menu(menu) x = int(ui.get_input("Enter a number: ")) if x == 1: create_position(file_name) elif x == 2: position_id = ui.get_input("Enter a position ID here: ") read_position(table, position_id) elif x== 3: read_positions(table) elif x == 4: position_id = ui.get_input("Enter a position ID here: ") update_position(table, file_name, position_id) elif x == 5: delete_position(table, file_name) elif x == 6: main.main()
def run_function(current_choice): choice = current_choice if choice == 0: dict_of_food = {} data_manager.add_food(dict_of_food) elif choice == 1: dict_of_excersises = {} data_manager.add_excersise(dict_of_excersises) elif choice == 2: dict_of_food = {} data_manager.show_list_of_food() x = data_manager.import_file(filename='food.txt') value = data_manager.calculate(x) data_manager.show_informations(value) pause() elif choice == 3: dict_of_excersises = {} data_manager.show_list_of_excersises() pause() elif choice == 4: sys.exit()
def create_application(file_name): ''' Users can create new applications. An application has an ID, an “accepted” field, a “Student ID” and a “Position ID”. IDs are unique amongst other applications. Student and Position IDs must exist. The “accepted” field stores whether the application was accepted by a company or not.''' application_ID = ui.generate_random() student_ID = input("Enter student ID here: ") position_ID = input("Enter position ID here: ") accepted = "Pending" application_data = [application_ID, accepted, student_ID, position_ID] for i in data_manager.import_file("student.csv"): if i[0] == student_ID: for j in data_manager.import_file("postion.csv"): if j[0] == position_ID: data_manager.export_file(application_data, file_name, "a")
def read_positions(table): for i in table: pos_count = 0 for j in data_manager.import_file("application.csv"): if i[0] == j[3] and j[1] == "Accepted": pos_count += 1 temp = i[2] i[2] = temp + "/" + str(pos_count) print(i) pass
def delete_position(table, file_name): position_id_by_user = ui.get_input("Enter position id: ") is_in_position = True for j in data_manager.import_file("application.csv"): if j[3] == position_id_by_user: is_in_position = False if is_in_position: for i in table: if i[0] == position_id_by_user: table.remove(i) data_manager.export_file(table, file_name, "w")
def create_position(file_name): ''' Users can create new positions. A position has an ID, description, number of seats and a “Company ID”. Position IDs are unique amongst other positions. Descriptions cannot be empty. The number of seats must be greater than 0. Company ID must exist.''' position_id = ui.generate_random() description = ui.get_input("Write position description: ") number_of_seat = ui.get_input("Enter the number of seats: ") company_id_position = ui.get_input("Enter company id: ") for i in data_manager.import_file("company.csv"): if i[0] == company_id_position: final_id = [ position_id, description, number_of_seat, company_id_position] data_manager.export_file(final_id, file_name, "a")
def delete_company(table, file_name): ''' Users can delete existing companies by entering their ID. Companies cannot be deleted if they have an existing “Position”.''' company_id_by_user = ui.get_input("Enter company id: ") is_in_position = True for j in data_manager.import_file("postion.csv"): if j[3] == company_id_by_user: is_in_position = False if is_in_position: for i in table: if i[0] == company_id_by_user: table.remove(i) data_manager.export_file(table, file_name, "w")
def start_module(): os.system('cls' if os.name == 'nt' else 'clear') file_name = "company.csv" table = data_manager.import_file(file_name) menu = [ "Create Company", "Read Company", "Read Companys", "Update Company", "Delete Company", "Back to main menu" ] ui.print_menu(menu) x = int(ui.get_input("Enter a number: ")) if x == 1: create_company(table, file_name) elif x == 2: read_company(table, file_name) elif x == 3: read_companys(table, file_name) elif x == 4: update_company(table, file_name) elif x == 5: delete_company(table, file_name) elif x == 6: main.main()
def start_module(): os.system('cls' if os.name == 'nt' else 'clear') file_name = "application.csv" table = data_manager.import_file(file_name) menu = [ "Create application", "Update application", "Delete application", "Back to main menu" ] ui.print_menu(menu) x = int(ui.get_input("Enter a number: ")) if x == 1: create_application(file_name) elif x == 2: application_ID = input("Enter an application ID: ") update_application(table, file_name, application_ID) elif x == 3: application_ID = input("Enter an application ID: ") delete_application(table, file_name, application_ID) elif x == 4: main.main()