Ignore:
Timestamp:
04/24/16 12:50:26 (8 years ago)
Author:
István Váradi <ivaradi@…>
Branch:
default
Phase:
public
Message:

The check flight can also be performed and the registration logic is hopefully complete (re #285)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/mlx/web.py

    r764 r769  
    9191                      const.AIRCRAFT_B462  : "146" }
    9292
     93    checkFlightTypes = [ const.AIRCRAFT_B736, const.AIRCRAFT_B737,
     94                         const.AIRCRAFT_B738, const.AIRCRAFT_DH8D ]
     95
    9396    @staticmethod
    9497    def getDateTime(date, time):
     
    9699        return datetime.datetime.strptime(date + " " + time,
    97100                                          "%Y-%m-%d %H:%M:%S")
     101
     102    @staticmethod
     103    def forCheckFlight(aircraftType):
     104        """Create a booked flight for a check flight with the given aircraft
     105        type."""
     106        flight = BookedFlight()
     107
     108        flight.departureICAO = "LHBP"
     109        flight.arrivalICAO = "LHBP"
     110
     111        flight.aircraftType = aircraftType
     112        flight.aircraftTypeName = BookedFlight.TYPE2TYPECODE[aircraftType]
     113
     114        # FIXME: perhaps find one for the type
     115        flight.tailNumber = "HA-CHK"
     116        flight.callsign = "HA-CHK"
     117
     118        flight.numPassengers = 0
     119        flight.numCrew = 2
     120        flight.bagWeight = 0
     121        flight.cargoWeight = 0
     122        flight.mailWeight = 0
     123        flight.route = "DCT"
     124
     125        t = datetime.datetime.now() + datetime.timedelta(minutes = 20)
     126        flight.departureTime = datetime.datetime(t.year, t.month, t.day,
     127                                                 t.hour, t.minute)
     128        t = flight.departureTime + datetime.timedelta(minutes = 30)
     129        flight.arrivalTime = datetime.datetime(t.year, t.month, t.day,
     130                                               t.hour, t.minute)
     131
     132        return flight
    98133
    99134    def __init__(self, id = None):
     
    741776                result.entryExamLink = reply[1]
    742777                result.checkFlightStatus = reply[2]
     778                if reply[3]:
     779                    result.rank = "FO"
    743780
    744781        return result
     
    761798        result.entryExamLink = reply[1]
    762799        result.checkFlightStatus = reply[2]
     800        result.madeFO = reply[3]
    763801
    764802        return result
     
    11561194#------------------------------------------------------------------------------
    11571195
     1196class SetCheckFlightPassed(RPCRequest):
     1197    """A request to mark the user as one having passed the check flight."""
     1198    def __init__(self, client, callback, aircraftType):
     1199        """Construct the request for the given type."""
     1200        super(SetCheckFlightPassed, self).__init__(client, callback)
     1201        self._aircraftType = aircraftType
     1202
     1203    def run(self):
     1204        """Perform the update."""
     1205        aircraftType = BookedFlight.TYPE2TYPECODE[self._aircraftType]
     1206        self._client.setCheckFlightPassed(aircraftType)
     1207        return Result()
     1208
     1209#------------------------------------------------------------------------------
     1210
    11581211class Handler(threading.Thread):
    11591212    """The handler for the web services.
     
    12321285        self._addRequest(SendBugReport(callback, summary, description, email))
    12331286
     1287    def setCheckFlightPassed(self, callback, aircraftType):
     1288        """Mark the check flight as passed."""
     1289        self._addRequest(SetCheckFlightPassed(self._rpcClient,
     1290                                              callback, aircraftType))
     1291
    12341292    def run(self):
    12351293        """Process the requests."""
Note: See TracChangeset for help on using the changeset viewer.