Changeset 824:599a3e9cb025 for src/mlx


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

Pending flights can be deleted (re #307).

Location:
src/mlx
Files:
4 edited

Legend:

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

    r823 r824  
    544544        """Refly the given flight."""
    545545        self._addFlight(flight)
     546        self._updatePending()
     547
     548    def _updatePending(self):
     549        """Update the stuff depending on the set of pending flights."""
    546550        self._setupHelp()
    547551        self._updatePendingButton()
     
    54925496        self._removePendingFlight(bookedFlight)
    54935497        self._flightSelectionPage._reflyFlight(bookedFlight)
     5498
     5499    def deleteFlight(self, bookedFlight):
     5500        """Remove the given flight from the pending flight list."""
     5501        self._removePendingFlight(bookedFlight)
     5502        self._flightSelectionPage._updatePending()
    54945503
    54955504    def cancelFlight(self, reloadCallback):
  • src/mlx/gui/flightlist.py

    r823 r824  
    243243    ]
    244244
    245     def __init__(self, which, wizard):
     245    def __init__(self, which, wizard, window):
    246246        """Construct the frame with the given title."""
    247247        super(PendingFlightsFrame, self).__init__(xstr("pendflt_title_" + which))
     
    249249        self._which = which
    250250        self._wizard = wizard
     251        self._window = window
    251252
    252253        alignment = gtk.Alignment(xscale = 1.0, yscale = 1.0)
     
    277278        self._deleteButton = gtk.Button(xstr("pendflt_delete_" + which))
    278279        self._deleteButton.set_sensitive(False)
     280        self._deleteButton.connect("clicked", self._deleteClicked)
    279281        buttonBox.pack_start(self._deleteButton, False, False, 2)
    280282
     
    340342                self._wizard.reflyFlight(flight)
    341343
     344    def _deleteClicked(self, button):
     345        """Called when the Delete button is clicked."""
     346        dialog = gtk.MessageDialog(parent = self._window,
     347                                   type = MESSAGETYPE_QUESTION,
     348                                   message_format = xstr("flight_delete_question"))
     349
     350        dialog.add_button(xstr("button_no"), RESPONSETYPE_NO)
     351        dialog.add_button(xstr("button_yes"), RESPONSETYPE_YES)
     352
     353        dialog.set_title(WINDOW_TITLE_BASE)
     354        result = dialog.run()
     355        dialog.hide()
     356
     357        if result==RESPONSETYPE_YES:
     358            gui = self._wizard.gui
     359            gui.beginBusy(xstr("pendflt_refly_busy"))
     360            self.set_sensitive(False)
     361
     362            flightIDs = [self._flights[i].id
     363                        for i in self._flightList.selectedIndexes]
     364            gui.webHandler.deleteFlights(self._deleteResultCallback, flightIDs)
     365
     366    def _deleteResultCallback(self, returned, result):
     367        """Called when the deletion result is available."""
     368        gobject.idle_add(self._handleDeleteResult, returned, result)
     369
     370    def _handleDeleteResult(self, returned, result):
     371        """Handle the delete result."""
     372
     373        self.set_sensitive(True)
     374        gui = self._wizard.gui
     375        gui.endBusy()
     376
     377        print "PendingFlightsFrame._handleDeleteResult", returned, result
     378
     379        if returned:
     380            indexes = self._flightList.selectedIndexes
     381
     382            flights = [self._flights[index] for index in indexes]
     383
     384            self._flightList.removeFlights(indexes)
     385            for index in indexes[::-1]:
     386                del self._flights[index]
     387
     388            for flight in flights:
     389                self._wizard.deleteFlight(flight)
    342390
    343391#-----------------------------------------------------------------------------
     
    364412        vbox = gtk.VBox()
    365413
    366         self._reportedFrame = PendingFlightsFrame("reported", wizard)
     414        self._reportedFrame = PendingFlightsFrame("reported", wizard, self)
    367415        vbox.pack_start(self._reportedFrame, True, True, 2)
    368416
    369         self._rejectedFrame = PendingFlightsFrame("rejected", wizard)
     417        self._rejectedFrame = PendingFlightsFrame("rejected", wizard, self)
    370418        vbox.pack_start(self._rejectedFrame, True, True, 2)
    371419
  • src/mlx/rpc.py

    r821 r824  
    345345                          self._server.reflyFlights(sessionID, flightIDs))
    346346
     347    def deleteFlights(self, flightIDs):
     348        """Delete the flights with the given IDs."""
     349        self._performCall(lambda sessionID:
     350                          self._server.deleteFlights(sessionID, flightIDs))
     351
    347352    def _performCall(self, callFn, acceptResults = []):
    348353        """Perform a call using the given call function.
  • src/mlx/web.py

    r821 r824  
    12561256#------------------------------------------------------------------------------
    12571257
     1258class DeleteFlights(RPCRequest):
     1259    """A request to delete certain flights."""
     1260    def __init__(self, client, callback, flightIDs):
     1261        """Construct the request."""
     1262        super(DeleteFlights, self).__init__(client, callback)
     1263        self._flightIDs = flightIDs
     1264
     1265    def run(self):
     1266        """Perform the update."""
     1267        self._client.deleteFlights(self._flightIDs)
     1268        return Result()
     1269
     1270#------------------------------------------------------------------------------
     1271
    12581272class Handler(threading.Thread):
    12591273    """The handler for the web services.
     
    13411355        self._addRequest(ReflyFlights(self._rpcClient, callback, flightIDs))
    13421356
     1357    def deleteFlights(self, callback, flightIDs):
     1358        """Delete the flights with the given IDs."""
     1359        self._addRequest(DeleteFlights(self._rpcClient, callback, flightIDs))
     1360
    13431361    def run(self):
    13441362        """Process the requests."""
Note: See TracChangeset for help on using the changeset viewer.