Changeset 1034:4836f52b49cd


Ignore:
Timestamp:
03/14/22 09:58:58 (7 months ago)
Author:
István Váradi <ivaradi@…>
Branch:
python3
Phase:
public
Message:

Updated the flight type handling (re #357)

Files:
10 edited

Legend:

Unmodified
Added
Removed
  • locale/en/mlx.po

    r1033 r1034  
    13001300msgid "finish_fuel"
    13011301msgstr "Fuel used:"
    1302 
    1303 msgid "finish_type"
    1304 msgstr "_Type:"
    1305 
    1306 msgid "finish_type_tooltip"
    1307 msgstr "Select the type of the flight."
    13081302
    13091303msgid "finish_online"
  • locale/hu/mlx.po

    r1033 r1034  
    13011301msgid "finish_fuel"
    13021302msgstr "Elhasznált üzemanyag:"
    1303 
    1304 msgid "finish_type"
    1305 msgstr "_Típus:"
    1306 
    1307 msgid "finish_type_tooltip"
    1308 msgstr "Válaszd ki a repülés típusát."
    13091303
    13101304msgid "finish_online"
  • src/mlx/const.py

    r1033 r1034  
    300300FLIGHTTYPE_SCHEDULED = 0
    301301
    302 ## Flight type: old-timer
    303 FLIGHTTYPE_OLDTIMER = 1
    304 
    305302## Flight type: VIP
    306 FLIGHTTYPE_VIP = 2
     303FLIGHTTYPE_VIP = 1
    307304
    308305## Flight type: charter
    309 FLIGHTTYPE_CHARTER = 3
     306FLIGHTTYPE_CHARTER = 2
     307
     308## Flight type: old timer (not used anymore)
     309FLIGHTTYPE_OLDTIMER = -1
    310310
    311311#-------------------------------------------------------------------------------
    312312
    313313flightTypes = [ FLIGHTTYPE_SCHEDULED,
    314                 FLIGHTTYPE_OLDTIMER,
    315314                FLIGHTTYPE_VIP,
    316                 FLIGHTTYPE_CHARTER ]
     315                FLIGHTTYPE_CHARTER,
     316                FLIGHTTYPE_OLDTIMER ]
    317317
    318318#-------------------------------------------------------------------------------
    319319
    320320_flightTypeStrings = { FLIGHTTYPE_SCHEDULED : "scheduled",
    321                        FLIGHTTYPE_OLDTIMER : "ot",
    322321                       FLIGHTTYPE_VIP : "vip",
    323                        FLIGHTTYPE_CHARTER : "charter" }
     322                       FLIGHTTYPE_CHARTER : "charter",
     323                       FLIGHTTYPE_OLDTIMER : "ot" }
    324324
    325325def flightType2string(flightType):
  • src/mlx/flight.py

    r1033 r1034  
    5454
    5555    @staticmethod
    56     def isTimeDifferenceTooMuch(scheduledTime, realTimestamp):
     56    def isTimeDifferenceTooMuch(scheduledTime, realTimestamp,
     57                                earlyOnlyWarning = False):
    5758        """Determine if the given real time differs to much from the scheduled
    5859        time.
     
    7172
    7273        return (diff>Flight.TIME_WARNING_DIFFERENCE,
    73                 diff>Flight.TIME_ERROR_DIFFERENCE)
     74                False if earlyOnlyWarning else diff>Flight.TIME_ERROR_DIFFERENCE)
    7475
    7576    def __init__(self, logger, gui):
     
    385386          but an error as well."""
    386387        return self.isTimeDifferenceTooMuch(self.bookedFlight.arrivalTime,
    387                                             self.blockTimeEnd)
     388                                            self.blockTimeEnd,
     389                                            earlyOnlyWarning = True)
    388390
    389391    def disconnected(self):
  • src/mlx/gui/flight.py

    r1033 r1034  
    23292329        self._bagWeight.set_sensitive(True)
    23302330
    2331         if bookedFlight.flightType==BookedFlight.FLIGHT_TYPE_CHARTER:
     2331        if bookedFlight.flightType==const.FLIGHTTYPE_CHARTER:
    23322332            self._cargoWeight.set_int(0)
    23332333            self._cargoWeight.set_sensitive(False)
     
    23652365        zfw += self._numPassengers.get_int() * \
    23662366            (const.WEIGHT_PASSENGER_CHARTER
    2367              if bookedFlight.flightType==BookedFlight.FLIGHT_TYPE_CHARTER
     2367             if bookedFlight.flightType==const.FLIGHTTYPE_CHARTER
    23682368             else const.WEIGHT_PASSENGER)
    23692369        zfw += self._numChildren.get_int() * const.WEIGHT_CHILD
     
    51075107        table.attach(labelAlignment, 0, 1, row, row+1)
    51085108
    5109         self._flightType = createFlightTypeComboBox()
    5110         self._flightType.set_tooltip_text(xstr("finish_type_tooltip"))
    5111         self._flightType.set_active(0)
    5112         self._flightType.connect("changed", self._flightTypeChanged)
    5113         flightTypeAlignment = Gtk.Alignment(xalign=0.0, xscale=0.0)
    5114         flightTypeAlignment.add(self._flightType)
    5115         table.attach(flightTypeAlignment, 1, 2, row, row+1)
    5116         label.set_mnemonic_widget(self._flightType)
    5117 
    5118         row += 1
    5119 
    51205109        self._onlineFlight = Gtk.CheckButton(xstr("finish_online"))
    51215110        self._onlineFlight.set_use_underline(True)
     
    51785167
    51795168    @property
    5180     def flightType(self):
    5181         """Get the flight type."""
    5182         index = self._flightType.get_active()
    5183         return None if index<0 else self._flightType.get_model()[index][1]
    5184 
    5185     @property
    51865169    def online(self):
    51875170        """Get whether the flight was an online flight or not."""
     
    52155198                                  (flight.startFuel - flight.endFuel,))
    52165199
    5217         self._flightType.set_active(-1)
    52185200        self._onlineFlight.set_active(self._wizard.loggedIn)
    52195201
     
    52405222        gui = self._wizard.gui
    52415223        faultsExplained = gui.faultsFullyExplained
    5242         timesCorrect = self.flightType is None or \
    5243                        not self._tooBigTimeDifference or \
     5224        timesCorrect = not self._tooBigTimeDifference or \
    52445225                       gui.hasComments or gui.hasDelayCode
    52455226        sensitive = gui.flight is not None and \
    52465227                    gui.flight.stage==const.STAGE_END and \
    5247                     self._flightType.get_active()>=0 and \
    52485228                    (self._gatesModel.get_iter_first() is None or
    52495229                     self._gate.get_active()>=0) and \
     
    52815261        """Called when the Back button is pressed."""
    52825262        self.goBack()
    5283 
    5284     def _flightTypeChanged(self, comboBox):
    5285         """Called when the flight type has changed."""
    5286         self._updateTimes()
    52875263
    52885264    def _gateChanged(self, comboBox):
     
    53745350        (arrivalWarning, arrivalError) = flight.blockTimeEndWrong
    53755351
    5376         if self.flightType==const.FLIGHTTYPE_VIP:
     5352        if bookedFlight.flightType==const.FLIGHTTYPE_VIP:
    53775353            departureError = arrivalError = False
    53785354
    5379         self._tooBigTimeDifference = departureError or arrivalError
     5355        self._tooBigTimeDifference = departureError and arrivalError
    53805356
    53815357        self._depTime.set_markup(self._formatTime(bookedFlight.departureTime,
  • src/mlx/gui/pirep.py

    r1033 r1034  
    387387        self._flownMailWeight.set_text("%.0f" % (pirep.mailWeight,))
    388388        self._flightType.set_text(xstr("flighttype_" +
    389                                        flightType2string(pirep.flightType)))
     389                                       flightType2string(pirep.bookedFlight.flightType)))
    390390        self._online.set_text(xstr("pirepView_" +
    391391                                   ("yes" if pirep.online else "no")))
     
    956956        self._flownCargoWeight.set_value(pirep.cargoWeight)
    957957        self._flownMailWeight.set_value(pirep.mailWeight)
    958         self._flightType.set_active(flightType2index(pirep.flightType))
     958        self._flightType.set_text(xstr("flighttype_" +
     959                                       flightType2string(pirep.bookedFlight.flightType)))
    959960        self._online.set_active(pirep.online)
    960961
     
    14441445        self._flownMailWeight.set_tooltip_text(xstr("payload_mail_tooltip"))
    14451446
    1446         self._flightType = createFlightTypeComboBox()
     1447        self._flightType = PIREPViewer.getDataLabel(width = 3)
    14471448        PIREPEditor.tableAttachWidget(table, 0, 2,
    14481449                                      xstr("pirepView_flightType"),
    14491450                                      self._flightType)
    1450         self._flightType.connect("changed", self._updateButtons)
    1451         self._flightType.set_tooltip_text(xstr("pirepEdit_flight_type_tooltip"))
    14521451
    14531452        self._online = Gtk.CheckButton(xstr("pirepEdit_online"))
     
    16081607        pirep.mailWeight = self._flownMailWeight.get_value()
    16091608
    1610         pirep.flightType = flightTypes[self._flightType.get_active()]
    16111609        pirep.online = self._online.get_active()
    16121610
  • src/mlx/gui/weighthelp.py

    r1033 r1034  
    44from mlx.i18n import xstr
    55from mlx.checks import PayloadChecker
    6 from mlx.rpc import BookedFlight
    76
    87import mlx.const as const
     
    441440            return self._pax * \
    442441                (const.WEIGHT_PASSENGER_CHARTER
    443                  if self._flightType==BookedFlight.FLIGHT_TYPE_CHARTER
     442                 if self._flightType==const.FLIGHTTYPE_CHARTER
    444443                 else const.WEIGHT_PASSENGER) + \
    445444                self._children * const.WEIGHT_CHILD + \
  • src/mlx/pirep.py

    r1033 r1034  
    4242
    4343    _flightTypes = { const.FLIGHTTYPE_SCHEDULED : "SCHEDULED",
    44                      const.FLIGHTTYPE_OLDTIMER : "OT",
    4544                     const.FLIGHTTYPE_VIP : "VIP",
    46                      const.FLIGHTTYPE_CHARTER : "CHARTER" }
     45                     const.FLIGHTTYPE_CHARTER : "CHARTER",
     46                     const.FLIGHTTYPE_OLDTIMER : "OT" }
    4747
    4848    @staticmethod
     
    167167        self.arrivalRunway = flight.arrivalRunway.upper()
    168168
    169         self.flightType = flight.flightType
    170169        self.online = flight.online
    171170
     
    237236        self.arrivalRunway = pirepData["arrivalRunway"]
    238237
    239         self.flightType = PIREP.decodeFlightTypeText(pirepData["flightType"])
    240238        self.online = int(pirepData["online"])!=0
    241239
     
    300298    def flightTypeText(self):
    301299        """Get the text representation of the flight type."""
    302         return PIREP._flightTypes[self.flightType]
     300        return PIREP._flightTypes[self.bookedFlight.flightType]
    303301
    304302    @property
     
    399397        attrs["bagWeight"] = self.bagWeight
    400398        attrs["mailWeight"] = self.mailWeight
    401         attrs["flightType"] = self.flightTypeText
    402399        attrs["online"] = 1 if self.online else 0
    403400        attrs["blockTimeStart"] = self.blockTimeStartText
  • src/mlx/rpc.py

    r1033 r1034  
    257257            raise Exception("Invalid flight status code: '" + status + "'")
    258258
     259    @staticmethod
     260    def _convertFlightType(ft):
     261        """Convert the in-database flight-type to one of our constants."""
     262        ft = int(ft)
     263        if ft==0:
     264            return const.FLIGHTTYPE_SCHEDULED
     265        elif ft==1:
     266            return const.FLIGHTTYPE_VIP
     267        elif ft==2:
     268            return const.FLIGHTTYPE_CHARTER
     269        else:
     270            return const.FLIGHTTYPE_SCHEDULED
     271
    259272    # FIXME: copied from web.BookedFlight
    260273    @staticmethod
     
    275288    # FIXME: copied from web.BookedFlight
    276289    STATUS_REJECTED = 4
    277 
    278     # Flight type: scheduled
    279     FLIGHT_TYPE_SCHEDULED = 0
    280 
    281     # Flight type: VIP
    282     FLIGHT_TYPE_VIP = 1
    283 
    284     # Flight type: charter
    285     FLIGHT_TYPE_CHARTER = 2
    286290
    287291    # The instructions for the construction
     
    296300        "cargoWeight" : int,
    297301        "mailWeight" : int,
    298         "flightType" : int,
     302        "flightType" : lambda value: BookedFlight._convertFlightType(value),
    299303        "dow": int,
    300304        "maxPassengers": int,
  • src/mlx/web.py

    r1033 r1034  
    147147        return flight
    148148
     149    @staticmethod
     150    def _convertFlightType(ft):
     151        """Convert the in-database flight-type to one of our constants."""
     152        ft = int(ft)
     153        if ft==0:
     154            return const.FLIGHTTYPE_SCHEDULED
     155        elif ft==1:
     156            return const.FLIGHTTYPE_VIP
     157        elif ft==2:
     158            return const.FLIGHTTYPE_CHARTER
     159        else:
     160            return const.FLIGHTTYPE_SCHEDULED
     161
    149162    def __init__(self, id = None):
    150163        """Construct a booked flight with the given ID."""
     
    295308        self.mailWeight = int(bookedFlightData["mailWeight"])
    296309        self.route = bookedFlightData["route"]
     310        self.flightType = BookedFlight._convertFlightType(bookedFlightData["flightType"])
    297311
    298312    def writeIntoFile(self, f):
Note: See TracChangeset for help on using the changeset viewer.