Changeset 821:158bfb360027


Ignore:
Timestamp:
09/25/16 06:42:50 (8 years ago)
Author:
István Váradi <ivaradi@…>
Branch:
default
Phase:
public
Message:

A flight can be marked for reflying (re #307).

Location:
src/mlx
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • src/mlx/gui/flight.py

    r819 r821  
    541541        self._flightList.addFlight(flight)
    542542
     543    def _reflyFlight(self, flight):
     544        """Refly the given flight."""
     545        self._addFlight(flight)
     546        self._setupHelp()
     547        self._updatePendingButton()
     548
    543549    def _pendingClicked(self, button):
    544550        """Called when the Pending flights button is clicked."""
     
    50805086        self._loginPage = LoginPage(self)
    50815087        self._pages.append(self._loginPage)
    5082         self._pages.append(FlightSelectionPage(self))
     5088        self._flightSelectionPage = FlightSelectionPage(self)
     5089        self._pages.append(self._flightSelectionPage)
    50835090        self._pages.append(GateSelectionPage(self))
    50845091        self._pages.append(RegisterPage(self))
     
    54815488        self.login(callback, None, None)
    54825489
     5490    def reflyFlight(self, bookedFlight):
     5491        """Add the given booked flight to the flight selection page."""
     5492        self._removePendingFlight(bookedFlight)
     5493        self._flightSelectionPage._reflyFlight(bookedFlight)
     5494
    54835495    def cancelFlight(self, reloadCallback):
    54845496        """Cancel the flight.
     
    55265538            if page is not originator:
    55275539                page.changeMETAR(metar)
     5540
     5541    def _removePendingFlight(self, flight):
     5542        """Remove the given pending flight from the login result."""
     5543        for flights in [self._loginResult.reportedFlights,
     5544                        self._loginResult.rejectedFlights]:
     5545            for f in flights:
     5546                if f.id==flight.id:
     5547                    flights.remove(f)
     5548                    return
    55285549
    55295550    def _loginResultCallback(self, returned, result):
  • src/mlx/gui/flightlist.py

    r819 r821  
    251251        self._reflyButton = gtk.Button(xstr("pendflt_refly_" + which))
    252252        self._reflyButton.set_sensitive(False)
     253        self._reflyButton.connect("clicked", self._reflyClicked)
    253254        buttonBox.pack_start(self._reflyButton, False, False, 2)
    254255
     
    284285        self._deleteButton.set_sensitive(sensitive)
    285286
     287    def _reflyClicked(self, button):
     288        """Called when the Refly button is clicked."""
     289        gui = self._wizard.gui
     290        gui.beginBusy(xstr("pendflt_refly_busy"))
     291        self.set_sensitive(False)
     292
     293        flight = self._flights[self._flightList.selectedIndex]
     294        gui.webHandler.reflyFlights(self._reflyResultCallback, [flight.id])
     295
     296    def _reflyResultCallback(self, returned, result):
     297        """Called when the refly result is available."""
     298        gobject.idle_add(self._handleReflyResult, returned, result)
     299
     300    def _handleReflyResult(self, returned, result):
     301        """Handle the refly result."""
     302
     303        self.set_sensitive(True)
     304        gui = self._wizard.gui
     305        gui.endBusy()
     306
     307        print "PendingFlightsFrame._handleReflyResult", returned, result
     308
     309        if returned:
     310            index = self._flightList.selectedIndex
     311
     312            flight = self._flights[index]
     313
     314            self._flightList.removeFlight(index)
     315            del self._flights[index]
     316
     317            self._wizard.reflyFlight(flight)
     318
     319
    286320#-----------------------------------------------------------------------------
    287321
  • src/mlx/rpc.py

    r820 r821  
    340340                          self._server.setCheckFlightPassed(sessionID, type))
    341341
     342    def reflyFlights(self, flightIDs):
     343        """Mark the flights with the given IDs for reflying."""
     344        self._performCall(lambda sessionID:
     345                          self._server.reflyFlights(sessionID, flightIDs))
     346
    342347    def _performCall(self, callFn, acceptResults = []):
    343348        """Perform a call using the given call function.
  • src/mlx/web.py

    r809 r821  
    12421242#------------------------------------------------------------------------------
    12431243
     1244class ReflyFlights(RPCRequest):
     1245    """A request to mark certain flights for reflying."""
     1246    def __init__(self, client, callback, flightIDs):
     1247        """Construct the request."""
     1248        super(ReflyFlights, self).__init__(client, callback)
     1249        self._flightIDs = flightIDs
     1250
     1251    def run(self):
     1252        """Perform the update."""
     1253        self._client.reflyFlights(self._flightIDs)
     1254        return Result()
     1255
     1256#------------------------------------------------------------------------------
     1257
    12441258class Handler(threading.Thread):
    12451259    """The handler for the web services.
     
    13231337                                              callback, aircraftType))
    13241338
     1339    def reflyFlights(self, callback, flightIDs):
     1340        """Mark the flights with the given IDs for reflying."""
     1341        self._addRequest(ReflyFlights(self._rpcClient, callback, flightIDs))
     1342
    13251343    def run(self):
    13261344        """Process the requests."""
Note: See TracChangeset for help on using the changeset viewer.