示例#1
0
    def handle_menu(user):
        '''
        Allows to choose an action to perform.
        '''
        options = ["View regular employees list",
                   "Add an employee",
                   "Edit employees' data",
                   "Fire an employee",
                   "View mentors list",
                   'Show the full statistics about mentors',
                   "Add a mentor",
                   "Edit mentors' data",
                   "Fire a mentor",
                   "View students list",
                   "View students' grades",
                   'Show full statistics about students']

        while True:
            os.system('clear')
            Ui.print_message(('\n...:::Logged in as {}:::...\n').format(user))
            Ui.print_menu("What you want to do?", options, "Log out")
            inputs = Ui.get_inputs(["Please enter a number: "], "")
            option = inputs[0]

            if option == '1':
                ManagerMenu.show_regular_employees()
                Ui.get_inputs([''], "Click enter to go back")

            elif option == '2':
                Employee.add_person(Employee.employees_list)
                Common.write_staff_to_file('database.db', Employee.employees_list)

            elif option == '3':
                # change regular employee's data
                ManagerMenu.show_regular_employees()
                person = Employee.choose_person_to_change_data(Employee.employees_list)
                if person:
                    Employee.data_to_change(person)
                    Common.write_staff_to_file('database.db', Employee.employees_list)

            elif option == '4':
                ManagerMenu.show_regular_employees()
                Employee.remove_person(Employee.employees_list)

            elif option == '5':
                ManagerMenu.show_mentors()
                Ui.get_inputs([''], "Click enter to go back")

            elif option == '6':
                #  Show full statistics about mentors
                ManagerMenu.show_mentors()
                Ui.get_inputs([''], "Click enter to go back")

            elif option == '7':
                Mentor.add_person(Mentor.mentors_list)
                Common.write_staff_to_file('database.db', Mentor.mentors_list)

            elif option == '8':
                # change mentor's data
                ManagerMenu.show_mentors()
                person = Mentor.choose_person_to_change_data(Mentor.mentors_list)
                if person:
                    Mentor.data_to_change(person)
                    Common.write_staff_to_file('database.db', Mentor.mentors_list)

            elif option == '9':
                # fire mentor
                ManagerMenu.show_mentors()
                Mentor.remove_person(Mentor.mentors_list)
                Common.write_staff_to_file('database.db', Mentor.mentors_list)

            elif option == '10':
                ManagerMenu.show_students()

            elif option == '11':
                ManagerMenu.show_average_of_grades()
                Ui.get_inputs([''], "Click enter to go back")

            elif option == '12':
                ManagerMenu.show_full_statistics_about_students()
                Ui.get_inputs([''], "Click enter to go back")

            elif option == '0':
                ManagerMenu.save()
                sys.exit()
            else:
                Ui.print_error_message('There is no such option.')