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/gui
Files:
2 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
Note: See TracChangeset for help on using the changeset viewer.