示例#1
0
 def get_flights_list(search):
     all_voyages_list = []
     old_voyages = Old_Voyage_LL.get_old_voyages_list(search)
     voyages = Voyage_LL.get_voyage_list(search, None)
     for voyage in voyages:
         all_voyages_list.append(Voyage_LL.create_old_voyage(voyage))
     return Flight_LL.get_flight_from_old_voyages(old_voyages)
示例#2
0
 def __get_destination_of_voyage(employee, voyages, time):
     for voyage in voyages:
         for day in Voyage_LL.get_voyage_working_days(voyage):
             if time.year == day.year and time.month == day.month and time.day == day.day:
                 for employee_id in voyage.get_employee_ids():
                     if employee_id == employee.get_id():
                         return Voyage_LL.get_destination_by_id(voyage.get_destination_id())
     1/0 #did not find destination
示例#3
0
    def get_working_employees(time):
        all_voyages = IO_API.get_data("voyage")
        same_day_voyages = []
        for voyage in all_voyages:
            for work_day in Voyage_LL.get_voyage_working_days(voyage):
                if work_day.year == time.year and work_day.month == time.month and work_day.day == time.day:
                    same_day_voyages += [voyage]

        working_employee_list = []
        for voyage in same_day_voyages:
            for ssn in voyage.get_employee_ids():
                working_employee_list += [Voyage_LL.get_employee_by_id(ssn)]
        return working_employee_list
示例#4
0
    def __get_employee_list(search, filter, time):
        '''Private method which gets the employee list according to the filter and search.'''


        employee_list = IO_API.get_data("employee")

        # Checks the filter
        filtered_employee_list = []
        if filter == "pilot" or filter == "cabin_crew":
            for employee in employee_list:
                if employee.get_job() == filter:
                    filtered_employee_list += [employee]

        elif filter == "all":
            filtered_employee_list = employee_list

        else:
            all_voyages = IO_API.get_data("voyage")
            same_day_voyages = []
            for voyage in all_voyages:
                for work_day in Voyage_LL.get_voyage_working_days(voyage):
                    if work_day.year == time.year and work_day.month == time.month and work_day.day == time.day:
                        same_day_voyages += [voyage]

            if filter == "working":
                filtered_employee_list = []
                for voyage in same_day_voyages:
                    for ssn in voyage.get_employee_ids():
                        filtered_employee_list += [Voyage_LL.get_employee_by_id(ssn)]

            elif filter == "not_working":
                working = []
                for voyage in same_day_voyages:
                    for ssn in voyage.get_employee_ids():
                        working += [Voyage_LL.get_employee_by_id(ssn)]


                filtered_employee_list = list(set(employee_list)-set(working))


        employee_list = filtered_employee_list
        # Checks the search
        if search != None:
            search_filtered_employee_list = []
            for employee in employee_list:
                if search.lower() in Employee_LL.get_list_info(employee).lower():
                    search_filtered_employee_list.append(employee)
        else:
            search_filtered_employee_list = employee_list

        return search_filtered_employee_list
示例#5
0
 def get_edit_info(item):
     if isinstance(item, Employee):
         return Employee_LL.get_edit_info(item)
     elif isinstance(item, Destination):
         return Destination_LL.get_edit_info(item)
     # -------------------------------------------
     elif isinstance(item, Voyage):
         return Voyage_LL.get_edit_info(item)
     #-------------------------
     elif type(item) == type(Flight()):
         return Flight_LL.get_edit_info(item)
     else:
         1 / 0
示例#6
0
    def get_work_week(item, time):
        work_week_days = []
        for i in range(7):
            work_week_days += [time + datetime.timedelta(i)]
        voyages = IO_API.get_data("voyage")

        info_list = []
        for voyage in voyages:
            for workday in Voyage_LL.get_voyage_working_days(voyage):
                for i in range(len(work_week_days)):
                    if workday == work_week_days[i]:
                        if item.get_id() in voyage.get_employee_ids():
                            destination = Voyage_LL.get_destination_by_id(
                                voyage.get_destination_id())
                            work_week_days[i] = (workday, destination)

        for i in range(len(work_week_days)):
            if not isinstance(work_week_days[i], datetime.datetime):
                work_week_days[i] = (work_week_days[i][0],
                                     work_week_days[i][1].get_country())
            else:
                work_week_days[i] = (work_week_days[i], None)
        return work_week_days
示例#7
0
    def get_available_employees(time):
        all_voyages = IO_API.get_data("voyage")
        same_day_voyages = []
        for voyage in all_voyages:
            for work_day in Voyage_LL.get_voyage_working_days(voyage):
                if work_day.year == time.year and work_day.month == time.month and work_day.day == time.day:
                    same_day_voyages += [voyage]

        available_employee_list = IO_API.get_data("employee")
        for voyage in same_day_voyages:
            for ssn in voyage.get_employee_ids():
                for employee in available_employee_list:
                    if employee.get_id() == ssn:
                        available_employee_list.remove(employee)

        return available_employee_list
示例#8
0
 def get_info(item):
     if isinstance(item, Employee):
         return Employee_LL.get_info(item)
     elif isinstance(item, Aircraft):
         return Aircraft_LL.get_info(item)
     elif isinstance(item, Destination):
         return Destination_LL.get_info(item)
     # -------------------------------------------
     elif isinstance(item, Voyage):
         return Voyage_LL.get_info(item)
     elif isinstance(item, Old_Voyage):
         return Old_Voyage_LL.get_info(item)
     #-------------------------------
     elif type(item) == type(Flight()):
         return Flight_LL.get_info(item)
     else:
         1 / 0  # BOMBA
示例#9
0
    def get_aircraft_status(aircraft_id, time_to_find):
        """ Takes in an aircraft id and returns its status. If it is unavailable then returns time when it will be available """

        time_to_find = Date_parser.date_parser(time_to_find)
        status = "Available"
        flight_info = "N/A"
        voyages_list = Aircraft_LL.get_voyages(aircraft_id)
        for voyage in voyages_list:
            destination = Voyage_LL.get_destination_by_id(
                voyage.get_destination_id())
            time_to_dest_str = destination.get_flight_time()
            departure_time, arrival_time, departure_2_time, arrival_2_time = Date_parser.get_arrival_times(
                str(voyage.get_departure_time()), time_to_dest_str)

            if departure_time <= time_to_find <= arrival_2_time:
                status = "Available on: " + str(arrival_2_time)
                if departure_time <= time_to_find <= arrival_time:
                    flight_info = voyage.flight1_number + " to " + destination.get_airport(
                    )
                elif departure_2_time <= time_to_find <= arrival_2_time:
                    flight_info = voyage.flight2_number + " to BIRK"

        return status, flight_info
示例#10
0
 def change_voyage(voyage_id, new_info):
     Voyage_LL.change_voyage(voyage_id, new_info)
示例#11
0
 def store_new_voyage(destination_id, departure_time):
     Voyage_LL.store_new_voyage(destination_id, departure_time)
示例#12
0
 def get_voyage_page(search, page, items_per_page, search_filter):
     return Voyage_LL.get_voyage_page(search, search_filter, page,
                                      items_per_page)
示例#13
0
 def get_number_of_voyages(search, manned_filter):
     return Voyage_LL.get_number_of_voyages(search, manned_filter)