Пример #1
0
 def ll_set_captain(self, trip_object, input_data):
     list_of_employees = DL_API().get_employees()
     list_of_captains = []
     list_of_planes = DL_API().get_planes()
     licence = ''
     valid = False
     list_of_licenced = []
     for plane in list_of_planes:
         if plane.get_insignia() == trip_object.get_plane():
             licence = plane.get_typeID()
     for employee in list_of_employees:
         if employee.get_rank() == 'Captain':
             list_of_captains.append(employee)
     for captain in list_of_captains:
         if captain.get_licence() == licence:
             list_of_licenced.append(captain)
     for licenced_cap in list_of_licenced:
         if licenced_cap.get_ssn() == input_data:
             if self.check_dates(input_data, trip_object):
                 trip_object.set_captain(input_data)
                 self.setStatus(trip_object)
                 valid = True
             else:
                 return 'This captain is working on this day.'
     if not valid:
         return 'This is not a licenced captain. Please try again.'
Пример #2
0
 def ll_set_out_dep(self, trip_object, input_data):
     try:
         dateutil.parser.parse(input_data)
     except ValueError:
         return "Could not understand date, plese use the format 'yyyy-mm-dd hh:mmm:ss'."
     if trip_object.get_destination() != '':
         departure = dateutil.parser.parse(input_data)
         list_of_destinations = DL_API().get_destinations()
         flight_time = ''
         for destination in list_of_destinations:
             if destination.get_airport_id().lower(
             ) == trip_object.get_destination().lower():
                 flight_time = destination.get_flight_time()
         flight_hours, flight_minutes, flight_seconds = flight_time.split(
             ':')
         flight = datetime.timedelta(hours=int(flight_hours),
                                     minutes=int(flight_minutes),
                                     seconds=int(flight_seconds))
         stop = datetime.timedelta(hours=1)
         iso_out_dep = datetime.datetime(departure.year, departure.month,
                                         departure.day, departure.hour,
                                         departure.minute, 0).isoformat()
         in_dep = departure + flight + stop
         iso_in_dep = datetime.datetime(in_dep.year, in_dep.month,
                                        in_dep.day, in_dep.hour,
                                        in_dep.minute, 0).isoformat()
         departure_buffer = datetime.timedelta(minutes=15)
         list_of_trips = DL_API().get_trips()
         list_of_departures = []
         for trip in list_of_trips:
             temp = trip.get_out_dep()
             if temp != '':
                 list_of_departures.append(dateutil.parser.parse(temp))
         if len(list_of_departures):
             for date_time in list_of_departures:
                 if date_time - departure_buffer <= departure <= date_time + departure_buffer:
                     return 'Another flight is scheduled for this timeslot. Please select another.'
                 else:
                     trip_object.set_out_dep(iso_out_dep)
                     trip_object.set_in_dep(iso_in_dep)
         else:
             trip_object.set_out_dep(iso_out_dep)
             trip_object.set_in_dep(iso_in_dep)
         self.setStatus(trip_object)
     else:
         return 'You have to set a destination before you select the departure time.'
Пример #3
0
 def search_plane(self, plane_object):
     list_of_planes = DL_API().get_planes()
     insignia_search = self.search_insignia(plane_object, list_of_planes)        
     typeID_search = self.search_typeID(plane_object, insignia_search)
     manufacturer_search = self.search_manufacturer(plane_object, typeID_search)
     model_search = self.search_model(plane_object, manufacturer_search)
     capacity_search = self.search_capacity(plane_object, model_search)
     return capacity_search
Пример #4
0
 def ll_set_destination(self, trip_object, input_data):
     list_of_destinations = DL_API().get_destinations()
     valid = False
     for destination in list_of_destinations:
         if destination.get_airport_id().lower() == input_data.lower():
             trip_object.set_destination(input_data)
             valid = True
     if not valid:
         return 'Destination not found. Please try again.'
Пример #5
0
 def create_flight_nr(self, trip_object):
     name, dest, no = 'NA', 0, 0
     list_of_destinations, list_of_trips, list_of_departures = DL_API(
     ).get_destinations(), DL_API().get_trips(), []
     for index, destination in enumerate(list_of_destinations):
         if destination.get_airport_id().lower(
         ) == trip_object.get_destination().lower():
             dest = '{:02d}'.format(index + 1)
     for trip in list_of_trips:
         if trip.get_destination() == trip_object.get_destination():
             list_of_departures.append(trip.get_out_dep())
     list_of_departures.sort()
     for index, departure in enumerate(list_of_departures):
         if departure == trip_object.get_out_dep():
             no = index * 2
     out_flight_nr = name + dest + str(no)
     in_flight_nr = name + dest + str(no + 1)
     trip_object.set_out_flight_nr(out_flight_nr)
     trip_object.set_in_flight_nr(in_flight_nr)
Пример #6
0
    def searchEmployee(self, employee_object):
        list_of_employees = DL_API().get_employees()
        ssn_search = self.search_ssn(employee_object, list_of_employees)
        name_search = self.search_name(employee_object, ssn_search)
        role_search = self.search_role(employee_object, name_search)
        rank_search = self.search_rank(employee_object, role_search)
        license_search = self.search_licence(employee_object, rank_search)
        address_search = self.search_address(employee_object, license_search)
        phonenumber_search = self.search_phonenumber(employee_object,
                                                     address_search)

        return phonenumber_search
Пример #7
0
 def ll_set_fa5(self, trip_object, input_data):
     list_of_employees = DL_API().get_employees()
     list_of_fa = []
     for employee in list_of_employees:
         if employee.get_rank() == 'Flight Attendant':
             list_of_fa.append(employee)
     for fa in list_of_fa:
         if fa.get_ssn() == input_data:
             if self.check_dates(input_data, trip_object):
                 trip_object.set_fa5(input_data)
                 self.setStatus(trip_object)
         else:
             return 'This is not a Flight Attendant. Please try again.'
Пример #8
0
 def ll_set_fsm(self, trip_object, input_data):
     list_of_employees = DL_API().get_employees()
     list_of_fsm = []
     for employee in list_of_employees:
         if employee.get_rank() == 'Flight Service Manager':
             list_of_fsm.append(employee)
     for fsm in list_of_fsm:
         if fsm.get_ssn() == input_data:
             if self.check_dates(input_data, trip_object):
                 trip_object.set_fsm(input_data)
                 self.setStatus(trip_object)
         else:
             return 'This is not a Flight Service Manager. Please try again.'
Пример #9
0
 def ll_set_copilot(self, trip_object, input_data):
     list_of_employees = DL_API().get_employees()
     list_of_copilots = []
     list_of_planes = DL_API().get_planes()
     licence = ''
     list_of_licenced = []
     for plane in list_of_planes:
         if plane.get_insignia() == trip_object.get_plane():
             licence = plane.get_typeID()
     for employee in list_of_employees:
         if employee.get_rank() == 'Copilot':
             list_of_copilots.append(employee)
     for copilot in list_of_copilots:
         if copilot.get_licence() == licence:
             list_of_licenced.append(copilot)
     for licenced_cop in list_of_licenced:
         if licenced_cop.get_ssn() == input_data:
             if self.check_dates(input_data, trip_object):
                 trip_object.set_copilot(input_data)
                 self.setStatus(trip_object)
         else:
             return 'This is not a licenced copilot. Please try again.'
Пример #10
0
 def search_destination(self, destination_object):
     list_of_destinations = DL_API().get_destinations()
     airportId_search = self.search_airportId(destination_object,
                                              list_of_destinations)
     destination_search = self.searchDestination(destination_object,
                                                 airportId_search)
     country_search = self.search_country(destination_object,
                                          destination_search)
     flightTime = self.search_flightTime(destination_object, country_search)
     distance_search = self.search_distance(destination_object, flightTime)
     ice_search = self.search_ice(destination_object, distance_search)
     iceNumber_search = self.search_iceNumber(destination_object,
                                              ice_search)
     return iceNumber_search
Пример #11
0
 def check_dates(self, input_data, trip_object):
     dep_out = dateutil.parser.parse(trip_object.get_out_dep())
     out_day = datetime.datetime(dep_out.year, dep_out.month, dep_out.day)
     list_of_destinations = DL_API().get_destinations()
     flight_times = []
     for destination in list_of_destinations:
         if destination.get_airport_id() == trip_object.get_destination():
             flight_times.append(destination.get_flight_time().split(':'))
     for flight in flight_times:
         flight_hours, flight_minutes, flight_seconds = flight
         flight = datetime.timedelta(hours=int(flight_hours),
                                     minutes=int(flight_minutes),
                                     seconds=int(flight_seconds))
         dep_in = dateutil.parser.parse(
             trip_object.get_in_dep()) + datetime.timedelta(flight)
         in_day = datetime.datetime(dep_in.year, dep_in.month, dep_in.day)
         list_of_trips = self.get_list_of_trips_by_employee(input_data)
         for trip in list_of_trips:
             test_dep_out = trip.get_out_dep()
             test_out_day = datetime.datetime(test_dep_out.year,
                                              test_dep_out.month,
                                              test_dep_out.day)
             flight_time = ''
             for destination in list_of_destinations:
                 if destination.get_airport_id(
                 ) == trip_object.get_destination():
                     flight_time = destination.get_flight_time()
                     flight_hours, flight_minutes, flight_seconds = flight_time.split(
                         ':')
                     flight = datetime.timedelta(
                         hours=int(flight_hours),
                         minutes=int(flight_minutes),
                         seconds=int(flight_seconds))
                 test_dep_in = trip.get_in_dep() + datetime.timedelta(
                     flight)
                 test_in_day = datetime.datetime(test_dep_in.year,
                                                 test_dep_in.month,
                                                 test_dep_in.day)
                 if out_day <= test_out_day <= in_day or out_day <= test_in_day <= in_day:
                     return 'This employee is already registerd for a trip on this day.'
     else:
         return True
Пример #12
0
 def get_list_of_trips_by_employee(self, input_data):
     list_of_trips = DL_API().get_trips()
     list_of_this_employee = []
     for trip in list_of_trips:
         if trip.get_captain() == input_data:
             list_of_this_employee.append(trip)
         elif trip.get_copilot() == input_data:
             list_of_this_employee.append(trip)
         elif trip.get_fsm() == input_data:
             list_of_this_employee.append(trip)
         elif trip.get_fa1() == input_data:
             list_of_this_employee.append(trip)
         elif trip.get_fa2() == input_data:
             list_of_this_employee.append(trip)
         elif trip.get_fa3() == input_data:
             list_of_this_employee.append(trip)
         elif trip.get_fa4() == input_data:
             list_of_this_employee.append(trip)
         elif trip.get_fa5() == input_data:
             list_of_this_employee.append(trip)
     return list_of_this_employee
Пример #13
0
 def search_trips(self, trip_object):
     list_of_trips = DL_API().get_trips()
     destination_search = self.search_destination(trip_object,
                                                  list_of_trips)
     plane_search = self.search_plane(trip_object, destination_search)
     captain_search = self.search_captain(trip_object, plane_search)
     copilot_search = self.search_copilot(trip_object, captain_search)
     outDep_search = self.search_out_dep(trip_object, copilot_search)
     inDep_search = self.search_in_dep(trip_object, outDep_search)
     capacity_search = self.search_capacity(trip_object, inDep_search)
     inFlightNo_search = self.search_in_flight_nr(trip_object,
                                                  capacity_search)
     outFlightNo_search = self.search_out_flight_nr(trip_object,
                                                    inFlightNo_search)
     fsm_search = self.search_fsm(trip_object, outFlightNo_search)
     fa1_search = self.search_fa1(trip_object, fsm_search)
     fa2_search = self.search_fa2(trip_object, fa1_search)
     fa3_search = self.search_fa3(trip_object, fa2_search)
     fa4_search = self.search_fa4(trip_object, fa3_search)
     fa5_search = self.search_fa5(trip_object, fa4_search)
     status_search = self.search_status(trip_object, fa5_search)
     return status_search
Пример #14
0
 def ll_set_plane(self, trip_object, input_data):
     if trip_object.get_out_dep() != '':
         list_of_planes = DL_API().get_planes()
         valid = False
         for plane in list_of_planes:
             if plane.get_insignia().lower() == input_data.lower():
                 trip_object.set_plane(input_data.upper())
                 capacity = plane.get_capacity()
                 trip_object.set_capacity(capacity)
                 self.setStatus(trip_object)
                 if not trip_object.get_captain(
                 ) == '' or not trip_object.get_copilot() == '':
                     trip_object.set_captain('')
                     trip_object.set_copilot('')
                 valid = True
         if valid:
             if trip_object.get_destination(
             ) != '' and trip_object.get_out_dep() != '':
                 self.create_flight_nr(trip_object)
         else:
             return 'Plane not found. Please try again.'
     else:
         return 'You need to set the date before you can set the plane.'
Пример #15
0
 def ll_set_ssn(self, employee_object, input_data):
     list_of_employees = DL_API().get_employees()
     valid = True
     for employee in list_of_employees:
         if employee.get_ssn() == input_data:
             valid = False
             break
     if valid:
         if employee_object.get_ssn() == '':
             ssn = ''
             for char in input_data:
                 if char in string.punctuation or char == ' ':
                     pass
                 else:
                     ssn += char
             if len(ssn) == 10:
                 return employee_object.set_ssn(ssn)
             else:
                 return 'Invalid SSN, please try again.'
         else:
             return 'This employee already has an SSN.'
     else:
         return 'This SSN is already in use.'
Пример #16
0
 def find_index_in_database(self, plane_object):
     list_of_planes = DL_API().get_planes()
     for index, plane in enumerate(list_of_planes):
         if plane.__str__() == plane_object.__str__():
             return index
     return None
Пример #17
0
 def add_plane(self, plane_object):
     return DL_API().append_planes(plane_object)
Пример #18
0
 def get_destination_file_headers(self):
     return DL_API().get_destinations_headers()
Пример #19
0
 def find_index_in_database(self, destination_object):
     list_of_destinations = DL_API().get_destinations()
     for index, destination in enumerate(list_of_destinations):
         if destination.__str__() == destination_object.__str__():
             return index
     return None
Пример #20
0
 def get_employee_file_headers(self):
     return DL_API().get_employee_headers()
Пример #21
0
 def find_index_in_database(self, employee_object):
     list_of_employees = DL_API().get_employees()
     for index, employee in enumerate(list_of_employees):
         if employee.__str__() == employee_object.__str__():
             return index
     return None
Пример #22
0
 def edit_employee_object(self, employeeEditObject, index):
     return DL_API().modify_employee(employeeEditObject, index)
Пример #23
0
 def edit_destination_object(self, destination_object, index):
     return DL_API().modify_destinations(destination_object, index)
Пример #24
0
 def add_employee(self, employee_object):
     return DL_API().append_employee(employee_object)
Пример #25
0
 def edit_plane_object(self, plane_object, index):
     return DL_API().modify_planes(plane_object, index)
Пример #26
0
 def find_index_in_database(self, trip_object):
     list_of_trips = DL_API().get_trips()
     for index, trip in enumerate(list_of_trips):
         if trip.__str__().lower() == trip_object.__str__().lower():
             return index
     return None
Пример #27
0
 def edit_trip_object(self, trip_object, index):
     return DL_API().modify_trips(trip_object, index)
Пример #28
0
 def add_trip(self, trip_object):
     return DL_API().append_trips(trip_object)
Пример #29
0
 def get_trips_file_headers(self):
     return DL_API().get_trips_headers()
Пример #30
0
 def add_destination(self, destination_object):
     return DL_API().append_destinations(destination_object)