Ignore:
Timestamp:
09/08/16 07:32:45 (8 years ago)
Author:
István Váradi <ivaradi@…>
Branch:
default
hg-Phase:
(<MercurialRepository 1 'hg:/home/ivaradi/mlx/hg' '/'>, 'public')
Message:

The past, pending flights are retrieved (re #307)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/mlx/rpc.py

    r790 r809  
    7373            raise Exception("Invalid aircraft type code: '" + typeCode + "'")
    7474
     75    @staticmethod
     76    def _decodeStatus(status):
     77        """Decode the status from the status string."""
     78        if status=="booked":
     79            return BookedFlight.STATUS_BOOKED
     80        elif status=="reported":
     81            return BookedFlight.STATUS_REPORTED
     82        elif status=="accepted":
     83            return BookedFlight.STATUS_ACCEPTED
     84        elif status=="rejected":
     85            return BookedFlight.STATUS_REJECTED
     86        else:
     87            raise Exception("Invalid flight status code: '" + status + "'")
     88
    7589    # FIXME: copied from web.BookedFlight
    7690    @staticmethod
     
    7993        return datetime.datetime.strptime(date + " " + time,
    8094                                          "%Y-%m-%d %H:%M:%S")
     95
     96    # FIXME: copied from web.BookedFlight
     97    STATUS_BOOKED = 1
     98
     99    # FIXME: copied from web.BookedFlight
     100    STATUS_REPORTED = 2
     101
     102    # FIXME: copied from web.BookedFlight
     103    STATUS_ACCEPTED = 3
     104
     105    # FIXME: copied from web.BookedFlight
     106    STATUS_REJECTED = 4
    81107
    82108    # The instructions for the construction
     
    87113        "cargoWeight" : int,
    88114        "mailWeight" : int,
    89         "aircraftType" : lambda value: BookedFlight._decodeAircraftType(value)
     115        "aircraftType" : lambda value: BookedFlight._decodeAircraftType(value),
     116        "status" : lambda value: BookedFlight._decodeStatus(value)
    90117        }
    91118
     
    246273    def getFlights(self):
    247274        """Get the flights available for performing."""
    248         flights = []
     275        bookedFlights = []
     276        reportedFlights = []
     277        rejectedFlights = []
    249278
    250279        value = self._performCall(lambda sessionID:
    251280                                  self._server.getFlights(sessionID))
    252281        for flightData in value:
    253             flights.append(BookedFlight(flightData))
    254 
    255         flights.sort(cmp = lambda flight1, flight2:
    256                      cmp(flight1.departureTime, flight2.departureTime))
    257 
    258         return flights
     282            flight = BookedFlight(flightData)
     283            if flight.status == BookedFlight.STATUS_BOOKED:
     284                bookedFlights.append(flight)
     285            elif flight.status == BookedFlight.STATUS_REPORTED:
     286                reportedFlights.append(flight)
     287            elif flight.status == BookedFlight.STATUS_REJECTED:
     288                rejectedFlights.append(flight)
     289
     290        for flights in [bookedFlights, reportedFlights, rejectedFlights]:
     291            flights.sort(cmp = lambda flight1, flight2:
     292                         cmp(flight1.departureTime, flight2.departureTime))
     293
     294        return (bookedFlights, reportedFlights, rejectedFlights)
    259295
    260296    def getEntryExamStatus(self):
Note: See TracChangeset for help on using the changeset viewer.