Changeset 853:28eb49544c0f


Ignore:
Timestamp:
05/21/17 07:42:48 (7 years ago)
Author:
István Váradi <ivaradi@…>
Branch:
default
Phase:
public
Message:

PIREP modifications can be saved (re #307)

Files:
6 edited

Legend:

Unmodified
Added
Removed
  • locale/en/mlx.po

    r848 r853  
    21002100msgstr ""
    21012101"The delay codes set. You should edit them in the 'Comments & defects' tab at the bottom."
     2102
     2103msgid "pirepEdit_save_question"
     2104msgstr "Are you sure to save the PIREP modifications?"
    21022105
    21032106msgid "about_website"
  • locale/hu/mlx.po

    r848 r853  
    21152115msgstr ""
    21162116"A megadott késési kódok. Szerkeszteni a 'Megjegyzések és hibák' fül alsó részén tudod."
     2117
     2118msgid "pirepEdit_save_question"
     2119msgstr "Biztosan el szeretnéd menteni a PIREP módosításait?"
    21172120
    21182121msgid "about_website"
  • src/mlx/gui/gui.py

    r845 r853  
    12661266        self._pirepEditor.setPIREP(pirep)
    12671267        self._pirepEditor.show_all()
    1268         self._pirepEditor.run()
     1268        if self._pirepEditor.run()==RESPONSETYPE_OK:
     1269            self.beginBusy(xstr("pirepEdit_save_busy"))
     1270            self.webHandler.sendPIREP(self._pirepUpdatedCallback, pirep,
     1271                                      update = True)
     1272        else:
     1273            self._pirepEditor.hide()
     1274
     1275    def _pirepUpdatedCallback(self, returned, result):
     1276        """Callback for the PIREP updating result."""
     1277        gobject.idle_add(self._handlePIREPUpdated, returned, result)
     1278
     1279    def _handlePIREPUpdated(self, returned, result):
     1280        """Callback for the PIREP updating result."""
     1281        self.endBusy()
     1282        secondaryMarkup = None
     1283        type = MESSAGETYPE_ERROR
     1284        if returned:
     1285            if result.success:
     1286                type = None
     1287            elif result.alreadyFlown:
     1288                messageFormat = xstr("sendPIREP_already")
     1289                secondaryMarkup = xstr("sendPIREP_already_sec")
     1290            elif result.notAvailable:
     1291                messageFormat = xstr("sendPIREP_notavail")
     1292            else:
     1293                messageFormat = xstr("sendPIREP_unknown")
     1294                secondaryMarkup = xstr("sendPIREP_unknown_sec")
     1295        else:
     1296            print "PIREP sending failed", result
     1297            messageFormat = xstr("sendPIREP_failed")
     1298            secondaryMarkup = xstr("sendPIREP_failed_sec")
     1299
     1300        if type is not None:
     1301            dialog = gtk.MessageDialog(parent = self._wizard.gui.mainWindow,
     1302                                       type = type, message_format = messageFormat)
     1303            dialog.add_button(xstr("button_ok"), RESPONSETYPE_OK)
     1304            dialog.set_title(WINDOW_TITLE_BASE)
     1305            if secondaryMarkup is not None:
     1306                dialog.format_secondary_markup(secondaryMarkup)
     1307
     1308            dialog.run()
     1309            dialog.hide()
     1310
    12691311        self._pirepEditor.hide()
    12701312
  • src/mlx/gui/pirep.py

    r849 r853  
    720720        self.add_button(xstr("button_cancel"), RESPONSETYPE_CANCEL)
    721721
    722         self._okButton = self.add_button(xstr("button_save"), RESPONSETYPE_OK)
     722        self._okButton = self.add_button(xstr("button_save"), RESPONSETYPE_NONE)
     723        self._okButton.connect("clicked", self._okClicked)
    723724        self._okButton.set_can_default(True)
    724725        self._modified = False
     726        self._toSave = False
    725727
    726728    def setPIREP(self, pirep):
     
    846848        self._updateButtons()
    847849        self._modified = True
     850        self._toSave = False
    848851
    849852    def delayCodesChanged(self):
     
    13631366                                     self._approachType.get_text()!="")
    13641367
     1368    def _okClicked(self, button):
     1369        """Called when the OK button has been clicked.
     1370
     1371        The PIREP is updated from the data in the window."""
     1372        if not askYesNo(xstr("pirepEdit_save_question"), parent = self):
     1373            self.response(RESPONSETYPE_CANCEL)
     1374
     1375        pirep = self._pirep
     1376
     1377        pirep.filedCruiseAltitude = \
     1378          self._filedCruiseLevel.get_value_as_int() * 100
     1379        pirep.cruiseAltitude = \
     1380          self._modifiedCruiseLevel.get_value_as_int() * 100
     1381
     1382        pirep.route = getTextViewText(self._userRoute)
     1383
     1384        pirep.departureMETAR = getTextViewText(self._departureMETAR)
     1385        pirep.departureRunway = self._departureRunway.get_text()
     1386        pirep.sid = self._sid.get_child().get_text()
     1387
     1388        pirep.arrivalMETAR = getTextViewText(self._arrivalMETAR)
     1389        pirep.star = None if self._star.get_active()==0 \
     1390          else self._star.get_child().get_text()
     1391        pirep.transition = None if self._transition.get_active()==0 \
     1392          else self._transition.get_child().get_text()
     1393        pirep.approachType = self._approachType.get_text()
     1394        pirep.arrivalRunway = self._arrivalRunway.get_text()
     1395
     1396        pirep.blockTimeStart = \
     1397          self._blockTimeStart.getTimestampFrom(pirep.blockTimeStart)
     1398        pirep.blockTimeEnd = \
     1399          self._blockTimeEnd.getTimestampFrom(pirep.blockTimeEnd)
     1400        pirep.flightTimeStart = \
     1401          self._flightTimeStart.getTimestampFrom(pirep.flightTimeStart)
     1402        pirep.flightTimeEnd = \
     1403          self._flightTimeEnd.getTimestampFrom(pirep.flightTimeEnd)
     1404
     1405        pirep.fuelUsed = self._fuelUsed.get_value()
     1406
     1407        pirep.numCrew = self._flownNumCrew.get_value()
     1408        pirep.numPassengers = self._flownNumPassengers.get_value()
     1409        pirep.bagWeight = self._flownBagWeight.get_value()
     1410        pirep.cargoWeight = self._flownCargoWeight.get_value()
     1411        pirep.mailWeight = self._flownMailWeight.get_value()
     1412
     1413        pirep.flightType = flightTypes[self._flightType.get_active()]
     1414        pirep.online = self._online.get_active()
     1415
     1416        pirep.delayCodes = self._flightInfo.delayCodes
     1417        pirep.comments = self._flightInfo.comments
     1418        pirep.flightDefects = self._flightInfo.faultsAndExplanations
     1419
     1420        self.response(RESPONSETYPE_OK)
     1421
     1422
    13651423#------------------------------------------------------------------------------
  • src/mlx/rpc.py

    r829 r853  
    321321                                                   status, gateNumber))
    322322
    323     def addPIREP(self, flightID, pirep):
     323    def addPIREP(self, flightID, pirep, update = False):
    324324        """Add the PIREP for the given flight."""
    325325        (result, _value) = \
    326326          self._performCall(lambda sessionID:
    327                             self._server.addPIREP(sessionID, flightID, pirep),
     327                            self._server.addPIREP(sessionID, flightID, pirep,
     328                                                  update),
    328329                            acceptResults = [Client.RESULT_FLIGHT_ALREADY_REPORTED,
    329330                                             Client.RESULT_FLIGHT_NOT_EXISTS])
  • src/mlx/web.py

    r829 r853  
    11441144    """A request to send a PIREP to the MAVA website via the RPC interface."""
    11451145
    1146     def __init__(self, client, callback, pirep):
     1146    def __init__(self, client, callback, pirep, update):
    11471147        """Construct the sending of the PIREP."""
    11481148        super(SendPIREPRPC, self).__init__(client, callback)
    11491149        self._pirep = pirep
     1150        self._update = update
    11501151
    11511152    def run(self):
    11521153        """Perform the sending of the PIREP."""
    11531154        pirep = self._pirep
    1154         resultCode = self._client.addPIREP(pirep.bookedFlight.id, pirep)
     1155        resultCode = self._client.addPIREP(pirep.bookedFlight.id, pirep,
     1156                                           self._update)
    11551157
    11561158        result = Result()
     
    12861288        print "pirepData:", pirepData
    12871289
    1288         bookedFlight = BookedFlight()
     1290        bookedFlight = BookedFlight(self._flightID)
    12891291        bookedFlight.setupFromPIREPData(pirepData)
    12901292
     
    13821384        self._addRequest(GetMETARs(callback, airports))
    13831385
    1384     def sendPIREP(self, callback, pirep):
     1386    def sendPIREP(self, callback, pirep, update = False):
    13851387        """Send the given PIREP."""
    13861388        request = \
    1387           SendPIREPRPC(self._rpcClient, callback, pirep) if self._config.useRPC \
    1388           else SendPIREP(callback, pirep)
     1389          SendPIREPRPC(self._rpcClient, callback, pirep, update) \
     1390          if self._config.useRPC else SendPIREP(callback, pirep)
    13891391        self._addRequest(request)
    13901392
Note: See TracChangeset for help on using the changeset viewer.