Пример #1
0
    def __show_all_flight_attendants():
        LogicAPI.update_states()  #UPDATES ALL STATES BEFOR DISPLAYING

        user_input = ""
        while user_input not in EmployeeUI.__NAVIGATION_BAR_OPTIONS:
            table_header_tuple = ("Name", "SSN", "Phone number",
                                  "Home address", "E-mail", "State")
            flight_attendants_list = LogicAPI.get_all_flight_attendants()
            flight_attendants_value_tuple = ([flight_attendant.get_name() for flight_attendant in flight_attendants_list],[flight_attendant.get_ssn() for flight_attendant in flight_attendants_list],\
            [flight_attendant.get_phonenumber() for flight_attendant in flight_attendants_list], [flight_attendant.get_home_address() for flight_attendant in flight_attendants_list],\
            [flight_attendant.get_email() for flight_attendant in flight_attendants_list], [flight_attendant.get_state() for flight_attendant in flight_attendants_list])
            table_height = len(flight_attendants_list)

            ComponentUI.print_frame_table_menu(table_header_tuple,
                                               flight_attendants_value_tuple,
                                               table_height,
                                               EmployeeUI.__FRAME_IN_USE_STR,
                                               "All flight attendants")
            user_input = ComponentUI.get_user_input()
            user_input = ComponentUI.remove_brackets(user_input)
            if not user_input.isdigit() or int(user_input) > table_height:
                continue
            table_index = int(user_input) - 1
            flight_attendant = flight_attendants_list[table_index]

            user_input = EmployeeUI.__show_employee(flight_attendant)

        return user_input
    def __show_airplanes_in_use():
        LogicAPI.update_states() #UPDATES ALL STATES BEFOR DISPLAYING


        ComponentUI.print_header(AirplanesUI.__FRAME_IN_USE_STR)
        print(TextEditor.format_text("All airplanes in use", TextEditor.UNDERLINE_TEXT))
        user_input = ""
        while user_input not in AirplanesUI.__NAVIGATION_BAR_OPTIONS:
            table_header_tuple = ("Name", "State", "Type", "Manufacturer", "Seats")
            airplanes_list = LogicAPI.get_all_airplanes_in_use()
            if airplanes_list:
                airplanes_getfunctions_tuple = ([airplane.get_name() for airplane in airplanes_list],[airplane.get_state() for airplane in airplanes_list],\
                [airplane.get_type() for airplane in airplanes_list], [airplane.get_manufacturer() for airplane in airplanes_list], [airplane.get_seat_count() for airplane in airplanes_list])
                table_height = len(airplanes_list)
                ComponentUI.print_frame_table_menu(table_header_tuple,airplanes_getfunctions_tuple, table_height, AirplanesUI.__FRAME_IN_USE_STR, "All airplanes in use")
                user_input = ComponentUI.get_user_input()
                user_input = ComponentUI.remove_brackets(user_input)
                if not user_input.isdigit() or int(user_input) > table_height:
                    continue
                table_index = int(user_input)-1
                airplane = airplanes_list[table_index]        

                user_input = AirplanesUI.__show_airplane(airplane)
            else:
                ComponentUI.print_header(AirplanesUI.__FRAME_IN_USE_STR)
                print(TextEditor.format_text("All airplanes in use", TextEditor.UNDERLINE_TEXT))
                ComponentUI.centered_text_message("There are no airplanes in use at the moment !","",3)

           
            return user_input
Пример #3
0
    def __show_all_employees():
        LogicAPI.update_states()  #UPDATES ALL STATES BEFOR DISPLAYING

        user_input = ""
        while user_input not in EmployeeUI.__NAVIGATION_BAR_OPTIONS:
            table_header_tuple = ("Job title", "Name", "SSN", "Phone number",
                                  "Home address", "E-mail", "State")
            all_employees_list = LogicAPI.get_all_employees()
            employees_getfunctions_tuple = (["Pilot" if isinstance(employee, Pilot) else "Flight attendant" for employee in all_employees_list], [employee.get_name() for employee in all_employees_list],[employee.get_ssn() for employee in all_employees_list],\
            [employee.get_phonenumber() for employee in all_employees_list],[employee.get_home_address() for employee in all_employees_list],[employee.get_email() for employee in all_employees_list],\
            [employee.get_state() for employee in all_employees_list])
            table_height = len(all_employees_list)
            ComponentUI.print_frame_table_menu(table_header_tuple,
                                               employees_getfunctions_tuple,
                                               table_height,
                                               EmployeeUI.__FRAME_IN_USE_STR,
                                               "All employees")
            user_input = ComponentUI.get_user_input()
            user_input = ComponentUI.remove_brackets(user_input)
            if not user_input.isdigit() or int(user_input) > table_height:
                continue
            table_index = int(user_input) - 1
            employee = all_employees_list[table_index]

            user_input = EmployeeUI.__show_employee(employee)

        return user_input
Пример #4
0
    def __show_pilot_by_license_finder():
        LogicAPI.update_states()  #UPDATES ALL STATES BEFOR DISPLAYING

        user_input = ""

        info_header_tuple = ("Name", "SSN", "Phone number", "Home address",
                             "E-mail", "State")

        while user_input not in EmployeeUI.__NAVIGATION_BAR_OPTIONS:
            ComponentUI.print_header(EmployeeUI.__FRAME_IN_USE_STR)
            #display table of airplane types and return the type-name the of chosen one , head above the the table
            user_input = EmployeeUI.__airplane_type_picker(
                "Find pilots by license")

            if not user_input:
                continue

            user_input = user_input

            pilots_list = []

            pilots_list = LogicAPI.get_licensed_pilots(user_input)

            ComponentUI.print_header(EmployeeUI.__FRAME_IN_USE_STR)

            if not pilots_list:
                print(
                    TextEditor.format_text("Find pilots by license",
                                           TextEditor.UNDERLINE_TEXT))
                ComponentUI.centered_text_message(
                    "Could not find a pilot with a license for {}".format(
                        user_input), "", 3)
                user_input = ComponentUI.get_user_input()
                if not user_input:
                    return EmployeeUI.__show_pilot_by_license_finder()

                return user_input

            else:
                #print(TextEditor.format_text("Pilots with license for " + user_input, TextEditor.UNDERLINE_TEXT))
                pilot_info_tuple = ([pilot.get_name() for pilot in pilots_list],[pilot.get_ssn() for pilot in pilots_list],\
                [pilot.get_phonenumber() for pilot in pilots_list],[pilot.get_home_address() for pilot in pilots_list],[pilot.get_email() for pilot in pilots_list],\
                [pilot.get_state() for pilot in pilots_list])
                table_height = len(pilots_list)
                ComponentUI.print_frame_table_menu(
                    info_header_tuple, pilot_info_tuple, table_height,
                    EmployeeUI.__FRAME_IN_USE_STR,
                    "Pilots with license for " + user_input)
                user_input = ComponentUI.get_user_input()
                user_input = ComponentUI.remove_brackets(user_input)
                if not user_input.isdigit() or int(user_input) > table_height:
                    continue
                table_index = int(user_input) - 1
                employee = pilots_list[table_index]

                user_input = EmployeeUI.__show_employee(employee)

            return user_input
Пример #5
0
    def __show_employees_off_duty():
        LogicAPI.update_states()  #UPDATES ALL STATES BEFOR DISPLAYING

        ComponentUI.print_header(EmployeeUI.__FRAME_IN_USE_STR)
        print(
            TextEditor.format_text("All employees off duty",
                                   TextEditor.UNDERLINE_TEXT))
        user_input = ""
        while user_input not in EmployeeUI.__NAVIGATION_BAR_OPTIONS:
            table_header_tuple = ("Name", "SSN", "Phone number",
                                  "Home address", "E-mail", "State")
            employees_off_duty_list = LogicAPI.get_employees_off_duty()
            if employees_off_duty_list:
                employees_off_duty_value_tuple = ([employees_off_duty.get_name() for employees_off_duty in employees_off_duty_list],[employees_off_duty.get_ssn() for employees_off_duty in employees_off_duty_list],\
                [employees_off_duty.get_phonenumber() for employees_off_duty in employees_off_duty_list], [employees_off_duty.get_home_address() for employees_off_duty in employees_off_duty_list],\
                [employees_off_duty.get_email() for employees_off_duty in employees_off_duty_list], [employees_off_duty.get_state() for employees_off_duty in employees_off_duty_list])
                table_height = len(employees_off_duty_list)
                ComponentUI.print_frame_table_menu(
                    table_header_tuple, employees_off_duty_value_tuple,
                    table_height, EmployeeUI.__FRAME_IN_USE_STR,
                    "All employees off duty")
                user_input = ComponentUI.get_user_input()
                user_input = ComponentUI.remove_brackets(user_input)
                if not user_input.isdigit() or int(user_input) > table_height:
                    continue
                table_index = int(user_input) - 1
                employee_off_duty = employees_off_duty_list[table_index]

                user_input = EmployeeUI.__show_employee(employee_off_duty)

            else:
                ComponentUI.print_header(EmployeeUI.__FRAME_IN_USE_STR)
                print(
                    TextEditor.format_text("Employees off duty",
                                           TextEditor.UNDERLINE_TEXT))

                ComponentUI.centered_text_message(
                    "No employee is off duty at the moment", "", 3)
                user_input = ComponentUI.get_user_input()

            return user_input
    def __show_airplane(airplane):
        LogicAPI.update_states() #UPDATES ALL STATES BEFOR DISPLAYING

        user_input = ''
        user_input_list = [
            airplane.get_name(),
            airplane.get_type(),
            airplane.get_manufacturer(),
            airplane.get_seat_count(),
            airplane.get_state()
        ]
        valid_user_inputs = ["1"]
        option_tuple = ('Name', 'Type', 'Manufacturer', "Seats", 'State')          
        valid_for_submit_list = [False] #Can only change the name (one element) in this case (airplane)
        while user_input not in AirplanesUI.__NAVIGATION_BAR_OPTIONS:
            ComponentUI.print_frame_constructor_menu(option_tuple,\
            ComponentUI.get_main_options()[2], "Edit mode", user_input_list, True, 1000, [1,2,3,4])

            user_input = ComponentUI.get_user_input()
            user_input = ComponentUI.remove_brackets(user_input)
            if user_input in valid_user_inputs: 
                index = int(user_input) - 1
                ComponentUI.print_frame_constructor_menu(option_tuple,\
                    ComponentUI.get_main_options()[2], "Edit mode", user_input_list, False, 1000, [1,2,3,4])

                if(index == 0):
                    user_input = input("Insert name: ").strip()
                



                #Capitalize the first letters in the contacts name
                if index == 0:
                    if not user_input: #use existing name in case if user cancels or leaves it blank 
                        user_input = user_input_list[index]

                    airplane_name_list = []
                    for name in user_input.split():
                        airplane_name_list.append(name.capitalize())
                    user_input = " ".join(airplane_name_list)
                    valid_for_submit_list[0] = True

              
                
                user_input_list[index] = user_input
                user_input = ""
                   
            elif user_input.startswith('s'):
                if all(user_input_list):

                    edited_airplane = Airplane(
                        user_input_list[0],
                        user_input_list[1],
                        user_input_list[2],
                        user_input_list[3],
                        user_input_list[4]

                    )

                    LogicAPI.change_saved_airplane(airplane, edited_airplane)
                    
                    
                    user_input = "An airplane has been edited"
                    break
        return user_input
Пример #7
0
    def __show_employee(employee):
        LogicAPI.update_states()  #UPDATES ALL STATES BEFOR DISPLAYING

        user_input = ''
        user_input_list = []
        valid_user_inputs_bool_list = [True] * 7

        is_pilot = isinstance(employee, Pilot)

        user_input_list.append(employee.get_name())
        user_input_list.append(employee.get_ssn())
        user_input_list.append(employee.get_phonenumber())
        user_input_list.append(employee.get_home_address())
        user_input_list.append(employee.get_email())
        user_input_list.append(employee.get_state())

        valid_user_inputs = ["4", "5", "6"]
        invalid_user_input_index_list = [0, 1, 2, 6]

        if is_pilot:
            user_input_list.append(employee.get_license())
            valid_user_inputs_bool_list.append(True)
            valid_user_inputs.append("8")
            user_input_list.insert(0, "Pilot")
            option_tuple = ("Job title", "Name", "SSN", "Phonenumber",
                            "Home address", "Email", "State", "License")
        else:
            user_input_list.insert(0, "Flight Attendant")
            invalid_user_input_index_list.append(7)
            option_tuple = ("Job title", "Name", "SSN", "Phonenumber",
                            "Home address", "Email", "State")

        # employee_info_already_exists = False
        while user_input not in EmployeeUI.__NAVIGATION_BAR_OPTIONS:
            ComponentUI.print_frame_constructor_menu(option_tuple,\
            ComponentUI.get_main_options()[1], "Edit mode", user_input_list, True, 1000, invalid_user_input_index_list, print_check_voyages=True)

            user_input = ComponentUI.get_user_input()
            user_input = ComponentUI.remove_brackets(user_input)
            if user_input in valid_user_inputs:
                index = int(user_input) - 1
                ComponentUI.print_frame_constructor_menu(option_tuple,\
            ComponentUI.get_main_options()[1], "Edit mode", user_input_list, False, index, invalid_user_input_index_list)

                if index == 3:
                    user_input = input("Insert new phone number: ").strip()
                elif index == 4:
                    user_input = input("Insert new home address: ").strip()
                elif index == 5:
                    user_input = input("Insert new e-mail: ").strip()
                elif index == 7 and is_pilot:
                    user_input = EmployeeUI.__airplane_type_picker(
                        "Edit mode - choose license"
                    )  # input("Insert new license: ").strip() #Vantar sub menu

                if not user_input and (index == 2 or index == 3 or index == 4):
                    user_input = user_input_list[index]
                else:

                    user_input = EmployeeUI.__constructor_error_check(user_input, valid_user_inputs_bool_list,\
                            index, user_input_list)

            elif user_input.startswith('s'):
                if all(user_input_list) and all(valid_user_inputs_bool_list):

                    edited_employee = None

                    if is_pilot:
                        edited_employee = Pilot(
                            user_input_list[1],  #Name
                            user_input_list[2],  #SSN
                            user_input_list[3],  #Phonenumber
                            user_input_list[4],  #Home address
                            user_input_list[5],  #Email
                            user_input_list[6],  #State
                            user_input_list[7]  #License
                        )
                        LogicAPI.change_saved_pilot(employee, edited_employee)
                    else:
                        edited_employee = FlightAttendant(
                            user_input_list[1],  #Name
                            user_input_list[2],  #SSN
                            user_input_list[3],  #Phonenumber
                            user_input_list[4],  #Home address
                            user_input_list[5],  #Email
                            user_input_list[6]  #State
                        )
                        LogicAPI.change_saved_flight_attendant(
                            employee, edited_employee)

                    #þarfnast skoðunnar(Kannski er þetta ok þar sem breytingar sjást, næ ekki að láta þetta virka heldur)
                    user_input = "An employee has been edited"
                    break

            elif user_input.startswith('c'):
                user_input = EmployeeUI.__show_employee_voyages(employee)

        return user_input
Пример #8
0
    def __show_employee_by_name_finder():
        LogicAPI.update_states()  #UPDATES ALL STATES BEFOR DISPLAYING

        user_input = ""

        info_header_tuple = ("Job title", "Name", "SSN", "Phone number",
                             "Home address", "E-mail", "State")

        while user_input not in EmployeeUI.__NAVIGATION_BAR_OPTIONS:
            ComponentUI.print_header(EmployeeUI.__FRAME_IN_USE_STR)
            print(
                TextEditor.format_text("Find employee by name or ssn",
                                       TextEditor.UNDERLINE_TEXT))

            ComponentUI.fill_window_and_print_action_line(1)

            user_input = input("Insert name or ssn: ").strip()

            employees = []

            if not user_input:
                continue

            #If he enters  a digit
            if user_input.isdigit():
                if '-' in user_input:
                    user_input = user_input.replace('-', '')
                if ' ' in user_input:
                    user_input = user_input.replace(' ', '')

                employees = LogicAPI.get_employee_by_ssn(user_input)

                ComponentUI.print_header(EmployeeUI.__FRAME_IN_USE_STR)
                print(
                    TextEditor.format_text("Find employee by name or ssn",
                                           TextEditor.UNDERLINE_TEXT))

                if not employees:
                    ComponentUI.centered_text_message(
                        "No employee found with the ssn: {}".format(
                            user_input), "", 3)

                    return ComponentUI.get_user_input()

                else:
                    employee_info_tuple =  (["Pilot" if isinstance(employee, Pilot) else "Flight attendant" for employee in employees], [employee.get_name() for employee in employees],[employee.get_ssn() for employee in employees],\
                    [employee.get_phonenumber() for employee in employees],[employee.get_home_address() for employee in employees],[employee.get_email() for employee in employees],\
                    [employee.get_state() for employee in employees])

                    table_height = len(employees)
                    ComponentUI.print_frame_table_menu(
                        info_header_tuple, employee_info_tuple, table_height,
                        EmployeeUI.__FRAME_IN_USE_STR, "Employee")
                    user_input = ComponentUI.get_user_input()
                    user_input = ComponentUI.remove_brackets(user_input)
                    if not user_input.isdigit() or int(
                            user_input) > table_height:
                        continue
                    table_index = int(user_input) - 1
                    employee = employees[table_index]

                    user_input = EmployeeUI.__show_employee(employee)

                return user_input
            else:
                name_list = []
                for name in user_input.split():
                    name_list.append(name.capitalize())

                user_input = " ".join(name_list)

                employees = LogicAPI.get_employee_by_name(user_input)

                ComponentUI.print_header(EmployeeUI.__FRAME_IN_USE_STR)
                print(
                    TextEditor.format_text("Find employee by name or ssn",
                                           TextEditor.UNDERLINE_TEXT))

                if not employees:

                    ComponentUI.centered_text_message(
                        "Could not find an employee named {}".format(
                            user_input), "", 3)

                    return ComponentUI.get_user_input()

                else:
                    employee_info_tuple =  (["Pilot" if isinstance(employee, Pilot) else "Flight attendant" for employee in employees], [employee.get_name() for employee in employees],[employee.get_ssn() for employee in employees],\
                    [employee.get_phonenumber() for employee in employees],[employee.get_home_address() for employee in employees],[employee.get_email() for employee in employees],\
                    [employee.get_state() for employee in employees])
                    table_height = len(employees)
                    ComponentUI.print_frame_table_menu(
                        info_header_tuple, employee_info_tuple, table_height,
                        EmployeeUI.__FRAME_IN_USE_STR, "Employee")
                    user_input = ComponentUI.get_user_input()
                    user_input = ComponentUI.remove_brackets(user_input)
                    if not user_input.isdigit() or int(
                            user_input) > table_height:
                        continue
                    table_index = int(user_input) - 1
                    employee = employees[table_index]

                    user_input = EmployeeUI.__show_employee(employee)

                return user_input