Changeset 769:d10b450fff75


Ignore:
Timestamp:
04/24/16 12:50:26 (9 years ago)
Author:
István Váradi <ivaradi@…>
Branch:
default
Phase:
public
Message:

The check flight can also be performed and the registration logic is hopefully complete (re #285)

Files:
6 edited

Legend:

Unmodified
Added
Removed
  • locale/en/mlx.po

    r764 r769  
    1 # English-language texts for the MAVA Logger X
     1
    22#
    33# István Váradi <ivaradi@gmail.com>, 2012
     
    23112311"the exam earlier. Note, that its status is updated only a few minutes "
    23122312"after passing the exam."
     2313
     2314msgid "student_check_flight_status"
     2315msgstr "Check flight:"
     2316
     2317msgid "student_check_flight_passed"
     2318msgstr "<span color=\"darkgreen\"><b>Passed</b></span>"
     2319
     2320msgid "student_check_flight_not_passed"
     2321msgstr "<span color=\"orange\"><b>Not yet passed</b></span>"
     2322
     2323msgid "student_check_flight"
     2324msgstr "Perform the _check flight"
     2325
     2326msgid "student_check_flight_tooltip"
     2327msgstr ""
     2328"Click this button to perform the check flight, after you have selected "
     2329"the airfract type to fly with. You will then have to perform a flight "
     2330"departing from and arriving at LHBP (Budapest Ferihegy Airport) with a "
     2331"proper SID and arrival transition."
     2332
     2333msgid "student_fo"
     2334msgstr "Congratulations!"
     2335
     2336msgid "student_fo_secondary"
     2337msgstr ""
     2338"You have received the rank of <b>First Officer</b> (FO).\n\n"
     2339"By clicking OK below, you will be taken to the flight selection page, "
     2340"from which you can perform your first real MAVA flight!"
     2341
     2342msgid "chkfinish_title"
     2343msgstr "Check flight finished"
     2344
     2345msgid "chkfinish_passed_begin"
     2346msgstr ""
     2347"<b><span size=\"xx-large\">Congratulations!</span></b>\n"
     2348"\n"
     2349"You have successfully completed your check flight."
     2350
     2351msgid "chkfinish_passed_fo"
     2352msgstr ""
     2353" \n\n"
     2354"You have received the rank of <b>First Officer</b> (FO)."
     2355
     2356msgid "chkfinish_passed_end"
     2357msgstr ""
     2358" \n\n"
     2359"You may wish to review the log if you have made any mistakes."
     2360
     2361msgid "chkfinish_failed"
     2362msgstr ""
     2363"Unfortunately, you have <b>failed</b> your check flight.\n"
     2364"\n"
     2365"You can review the log to check what mistakes you have committed."
     2366
     2367msgid "chkfinish_savepirep"
     2368msgstr ""
     2369" \n\n"
     2370"If you have further questions, you can save your PIREP\n"
     2371"and send the file to your mentor for a review and\n"
     2372"to receive helpful advice."
     2373
     2374msgid "chkfinish_next_student_begin"
     2375msgstr ""
     2376" \n\n"
     2377"The <i>Next</i> button takes you back to the <i>Student</i> page,"
     2378
     2379msgid "chkfinish_next_student_nothing"
     2380msgstr ""
     2381" \n"
     2382"where you can initiate another test flight or take your entry exam."
     2383
     2384msgid "chkfinish_next_student_no_exam"
     2385msgstr ""
     2386" \n"
     2387"where you can take your entry exam."
     2388
     2389msgid "chkfinish_next_student_no_flight"
     2390msgstr ""
     2391" \n"
     2392"where you can initiate another test flight."
     2393
     2394msgid "chkfinish_next"
     2395msgstr ""
     2396" \n\n"
     2397"The <i>Next</i> button takes you to the flight selection page,\n"
     2398"from which you can perform your first real MAVA flight!"
     2399
     2400msgid "chkfinish_updateweb_busy"
     2401msgstr "Updating check flight status..."
     2402
     2403msgid "chkfinish_passedset_failed"
     2404msgstr "Failed to update the check flight status"
     2405
     2406msgid "chkfinish_passedset_failed_title"
     2407msgstr "Update failure"
     2408
     2409msgid "chkfinish_passedset_failed_secondary"
     2410msgstr ""
     2411"You can retry later, or save your PIREP and send it "
     2412"to your mentor at MAVA, who can arrange for your flight "
     2413"to be accepted."
  • locale/hu/mlx.po

    r764 r769  
    781781msgstr "Emelke_dési profil:"
    782782
    783 msgid "simbrief_climb_profile_tootip"
     783msgid "simbrief_climb_profile_tooltip"
    784784msgstr "Válaszd ki az emelkedési profilt"
    785785
     
    787787msgstr "_Utazó profil:"
    788788
    789 msgid "simbrief_cruise_profile_tootip"
     789msgid "simbrief_cruise_profile_tooltip"
    790790msgstr "Válaszd ki az utazó profilt"
    791791
     
    793793msgstr "Süll_yedési profil:"
    794794
    795 msgid "simbrief_descent_profile_tootip"
     795msgid "simbrief_descent_profile_tooltip"
    796796msgstr "Válaszd ki a süllyedési profilt"
    797797
     
    22542254msgstr ""
    22552255"Gratulálunk! Ezennel a MAVA pilótája lettél\n"
    2256 "STU (student - tanuló) státuszban.\n"
     2256"STU (student - jelölt) státuszban.\n"
    22572257"\n"
    22582258"Pilóta azonosítód: <b>%s</b>.\n"
    22592259"\n"
    2260 "Most a tanulók oldala fog megjelenni,\n"
     2260"Most a jelöltek oldala fog megjelenni,\n"
    22612261"ahol kezdeményezheted a belépő teszt\n"
    22622262"kitöltését vagy elindíthatod az ellenőrző\n"
    22632263"repülést.\n"
    22642264"\n"
    2265 "A tanulók oldalára bármikor visszatérhetsz\n"
     2265"A jelöltek oldalára bármikor visszatérhetsz\n"
    22662266"ha elindítod a programot és bejelentkezel."
    22672267
     
    22692269msgstr ""
    22702270"Gratulálunk! Ezennel a MAVA pilótája lettél\n"
    2271 "STU (student - tanuló) státuszban.\n"
     2271"STU (student - jelölt) státuszban.\n"
    22722272"\n"
    22732273"Pilóta azonosítód: <b>%s</b>.\n"
     
    23002300
    23012301msgid "student_title"
    2302 msgstr "Tanuló"
     2302msgstr "Jelölt"
    23032303
    23042304msgid "student_help"
     
    23272327"Ha a gomb inaktív, a vizsgát korábban már sikeresen teljesítetted. "
    23282328"A gomb állapota csak néhány perccel a vizsga teljesítése után frissül."
     2329
     2330msgid "student_check_flight_status"
     2331msgstr "Ellenőrző repülés:"
     2332
     2333msgid "student_check_flight_passed"
     2334msgstr "<span color=\"darkgreen\"><b>Sikeres</b></span>"
     2335
     2336msgid "student_check_flight_not_passed"
     2337msgstr "<span color=\"orange\"><b>Még nem hajtottad végre</b></span>"
     2338
     2339msgid "student_check_flight"
     2340msgstr "Ellenőrző _repülés"
     2341
     2342msgid "student_check_flight_tooltip"
     2343msgstr ""
     2344"Miután kiválasztottad a kívánt repülőgép típust, erre a gombra kattintva "
     2345"elindíthatod az ellenőrző repülést. Ennek során egy LHBP-ről "
     2346"(a ferihegyi repülőtérről) induló és oda érkező repülést kell végezned "
     2347"megfelelő SID és érkezési transition alkalmazásával."
     2348
     2349msgid "student_fo"
     2350msgstr "Gratulálunk!"
     2351
     2352msgid "student_fo_secondary"
     2353msgstr ""
     2354"Megkaptad az <b>első tiszt</b> (FO) rangot.\n\n"
     2355"Ha az OK-ra kattintasz, a járatválasztó oldalra kerülsz, "
     2356"ahonnan teljesítheted az első igazi MAVA járatodat!"
     2357
     2358msgid "chkfinish_title"
     2359msgstr "Az ellenőrző repülés vége"
     2360
     2361msgid "chkfinish_passed_begin"
     2362msgstr ""
     2363"<b><span size=\"xx-large\">Gratulálunk!</span></b>\n"
     2364"\n"
     2365"Sikeresen teljesítetted az ellenőrző repülést."
     2366
     2367msgid "chkfinish_passed_fo"
     2368msgstr ""
     2369" \n\n"
     2370"A rangod <b>első tiszt</b> (FO) lett."
     2371
     2372msgid "chkfinish_passed_end"
     2373msgstr ""
     2374" \n\n"
     2375"Ha kívánod, a naplóban megnézheted, hogy vétettél-e valamilyen hibát."
     2376
     2377msgid "chkfinish_failed"
     2378msgstr ""
     2379"Sajnos az ellenőrző repülésed <b>sikertelen</b>.\n"
     2380"\n"
     2381"A naplóban megnézheted, milyen hibákat vétettel."
     2382
     2383msgid "chkfinish_savepirep"
     2384msgstr ""
     2385" \n\n"
     2386"Ha lennének további kérdéseid, a PIREP-et elmentheted, \n"
     2387"és elküldheted mentorodnak, hogy ő megnézhesse, és\n"
     2388"hasznos tanácsokkal szolgálhasson."
     2389
     2390msgid "chkfinish_next_student_begin"
     2391msgstr ""
     2392" \n\n"
     2393"Az <i>Előre</i> gomb visszavisz a <i>Jelölt</i> oldalra,"
     2394
     2395msgid "chkfinish_next_student_nothing"
     2396msgstr ""
     2397" \n"
     2398"ahol kezdeményezheted egy újabb ellenőrző repülés végrehajtását, "
     2399"vagy az elméleti vizsga letételét.."
     2400
     2401msgid "chkfinish_next_student_no_exam"
     2402msgstr ""
     2403" \n"
     2404"ahol kezdeményezheted az elméleti vizsga letételét."
     2405
     2406msgid "chkfinish_next_student_no_flight"
     2407msgstr ""
     2408" \n"
     2409"ahol egy újabb ellenőrző repülést kezdeményezhetsz."
     2410
     2411msgid "chkfinish_next"
     2412msgstr ""
     2413" \n\n"
     2414"Az <i>Előre</i> gombbal a járatválasztó oldara kerülsz,\n"
     2415"ahonnan elindíthatod első igazi MAVA járatod teljesítését!"
     2416
     2417msgid "chkfinish_updateweb_busy"
     2418msgstr "Az ellenőrző repülés státuszának frissítése..."
     2419
     2420msgid "chkfinish_passedset_failed"
     2421msgstr "Nem sikerült frissíteni az ellenőrző repülés státuszát"
     2422
     2423msgid "chkfinish_passedset_failed_title"
     2424msgstr "Frissítési hiba"
     2425
     2426msgid "chkfinish_passedset_failed_secondary"
     2427msgstr ""
     2428"Megpróbálhatod később, vagy elmentheted a PIREP-et, és "
     2429"elküldheted a mentorodnak, aki tesz róla, hogy elfogadják az "
     2430"ellenőrző repülésedet."
  • src/mlx/gui/flight.py

    r764 r769  
    169169
    170170    def addButton(self, label, default = False, sensitive = True,
    171                   tooltip = None, clicked = None, padding = 4):
     171                  tooltip = None, clicked = None, padding = 4,
     172                  clickedArg = None):
    172173        """Add a button with the given label.
    173174
     
    183184            button.set_tooltip_text(tooltip)
    184185        if clicked is not None:
    185             button.connect("clicked", clicked)
     186            if clickedArg is None:
     187                button.connect("clicked", clicked)
     188            else:
     189                button.connect("clicked", clicked, clickedArg)
    186190        return button
    187191
     
    13761380                                          xstr("student_help"))
    13771381
     1382
     1383        self._getEntryExamStatusCancelled = False
     1384
    13781385        alignment = gtk.Alignment(xalign = 0.5, yalign = 0.5,
    13791386                                  xscale = 0.5, yscale = 0.0)
    13801387
    1381         table = gtk.Table(2, 2)
     1388        table = gtk.Table(6, 4)
    13821389        table.set_row_spacings(4)
    1383         table.set_col_spacings(32)
     1390        table.set_col_spacings(0)
    13841391        table.set_homogeneous(False)
    13851392        alignment.add(table)
     
    13911398                                       xscale=0.0, yscale = 0.0)
    13921399        label = gtk.Label(xstr("student_entry_exam_status"))
     1400        label.set_alignment(0.0, 0.5)
    13931401        labelAlignment.add(label)
    1394         table.attach(labelAlignment, 0, 1, row, row + 1, xoptions = 0)
     1402        labelAlignment.resize_children()
     1403        table.attach(labelAlignment, 0, 1, row, row + 1, xoptions = FILL)
    13951404
    13961405        alignment = gtk.Alignment(xalign=0.0, yalign = 0.5,
     
    14001409        self._entryExamStatus.set_alignment(0.0, 0.5)
    14011410        alignment.add(self._entryExamStatus)
    1402         table.attach(alignment, 1, 2, row, row + 1)
     1411        alignment.resize_children()
     1412        table.attach(alignment, 1, 4, row, row + 1)
    14031413
    14041414        row += 1
     
    14111421
    14121422        buttonAlignment.add(button)
    1413         table.attach(buttonAlignment, 0, 2, row, row + 1,
     1423        table.attach(buttonAlignment, 0, 4, row, row + 1, xoptions = FILL,
    14141424                     ypadding = 4)
     1425
     1426        row += 3
     1427
     1428        labelAlignment = gtk.Alignment(xalign=0.0, yalign = 0.5,
     1429                                       xscale=0.0, yscale = 0.0)
     1430        label = gtk.Label(xstr("student_check_flight_status"))
     1431        labelAlignment.add(label)
     1432        table.attach(labelAlignment, 0, 1, row, row + 1, xoptions = FILL)
     1433
     1434        alignment = gtk.Alignment(xalign=0.0, yalign = 0.5,
     1435                                  xscale=1.0, yscale = 0.0)
     1436        self._checkFlightStatus = gtk.Label()
     1437        self._checkFlightStatus.set_use_markup(True)
     1438        self._checkFlightStatus.set_alignment(0.0, 0.5)
     1439        alignment.add(self._checkFlightStatus)
     1440        table.attach(alignment, 1, 4, row, row + 1)
     1441
     1442        row += 1
     1443
     1444        alignment = gtk.Alignment(xalign=0.0, xscale=1.0)
     1445
     1446        hbox = gtk.HBox()
     1447        hbox.set_homogeneous(False)
     1448        hbox.set_spacing(0)
     1449
     1450        aircraftTypesModel = gtk.ListStore(str, int)
     1451        for aircraftType in web.BookedFlight.checkFlightTypes:
     1452            aircraftTypesModel.append([aircraftNames[aircraftType],
     1453                                       aircraftType])
     1454
     1455        aircraftTypeAlignment = gtk.Alignment(xalign = 0.0, xscale = 1.0)
     1456
     1457        self._aircraftType = gtk.ComboBox(model = aircraftTypesModel)
     1458        renderer = gtk.CellRendererText()
     1459        self._aircraftType.pack_start(renderer, True)
     1460        self._aircraftType.add_attribute(renderer, "text", 0)
     1461        self._aircraftType.set_tooltip_text(xstr("student_check_flight_type_tooltip"))
     1462        self._aircraftType.set_active(0)
     1463
     1464        aircraftTypeAlignment.add(self._aircraftType)
     1465
     1466        hbox.pack_start(aircraftTypeAlignment, False, False, 0)
     1467
     1468        buttonAlignment = gtk.Alignment(xalign=0.0, xscale=1.0)
     1469        button = self._checkFlightButton = gtk.Button(xstr("student_check_flight"))
     1470        button.set_use_underline(True)
     1471        button.connect("clicked", self._checkFlightClicked)
     1472        button.set_tooltip_text(xstr("student_check_flight_tooltip"))
     1473
     1474        hbox.pack_start(button, True, True, 0)
     1475
     1476        alignment.add(hbox)
     1477        table.attach(alignment, 0, 4, row, row + 1, xoptions = FILL)
     1478
     1479    @property
     1480    def aircraftType(self):
     1481        """Get the type of the aircraft used to perform the check flight."""
     1482        index = self._aircraftType.get_active()
     1483        return self._aircraftType.get_model()[index][1]
    14151484
    14161485    def activate(self):
    14171486        """Activate the student page."""
     1487        print "StudentPage.activate"
     1488        self._getEntryExamStatusCancelled = False
     1489
    14181490        loginResult = self._wizard.loginResult
    14191491        self._entryExamLink = loginResult.entryExamLink
    14201492
    14211493        self._updateEntryExamStatus(loginResult.entryExamPassed)
    1422 
    14231494        self._getEntryExamStatus()
     1495
     1496        # FIXME: call with real value
     1497        self._updateCheckFlightStatus(self._wizard.loginResult.checkFlightStatus)
     1498
     1499    def finalize(self):
     1500        """Finalize the page."""
     1501        print "StudentPage.finalize"
     1502        self._getEntryExamStatusCancelled = True
    14241503
    14251504    def _entryExamClicked(self, button):
     
    14291508    def _getEntryExamStatus(self):
    14301509        """Initiate the query of the entry exam status after the interval."""
    1431         gobject.timeout_add(StudentPage._entryExamStatusQueryInterval,
    1432                             lambda: self._wizard.gui.webHandler. \
    1433                             getEntryExamStatus(self._entryExamStatusCallback))
     1510        if not self._getEntryExamStatusCancelled:
     1511            gobject.timeout_add(StudentPage._entryExamStatusQueryInterval,
     1512                                lambda: self._wizard.gui.webHandler. \
     1513                                getEntryExamStatus(self._entryExamStatusCallback))
    14341514
    14351515    def _entryExamStatusCallback(self, returned, result):
     
    14401520        """Called when the entry exam status is availabe."""
    14411521        print "_handleEntryExamStatus", returned, result
    1442         if returned:
     1522        if returned and not self._getEntryExamStatusCancelled:
    14431523            self._entryExamLink = result.entryExamLink
    14441524            self._updateEntryExamStatus(result.entryExamPassed)
    1445             self._getEntryExamStatus()
     1525            if result.madeFO:
     1526                self._madeFO()
     1527            else:
     1528                self._getEntryExamStatus()
    14461529
    14471530    def _updateEntryExamStatus(self, passed):
     
    14521535        self._entryExamStatus.set_use_markup(True)
    14531536        self._entryExamButton.set_sensitive(not passed)
     1537
     1538    def _checkFlightClicked(self, button):
     1539        """Called when the check flight button is clicked."""
     1540        aircraftType = self.aircraftType
     1541        self._wizard._bookedFlight = \
     1542            web.BookedFlight.forCheckFlight(aircraftType)
     1543        self._wizard.gui.enableFlightInfo(aircraftType)
     1544        self._wizard.jumpPage("connect")
     1545
     1546    def _updateCheckFlightStatus(self, passed):
     1547        """Update the status of the check flight."""
     1548        self._aircraftType.set_sensitive(not passed)
     1549        self._checkFlightStatus.set_text(xstr("student_check_flight_passed")
     1550                                         if passed else
     1551                                         xstr("student_check_flight_not_passed"))
     1552        self._checkFlightStatus.set_use_markup(True)
     1553        self._checkFlightButton.set_sensitive(not passed)
     1554
     1555    def _madeFO(self):
     1556        """Handle the event when the pilot has become a first officer."""
     1557        wizard = self._wizard
     1558        loginResult = wizard.loginResult
     1559        loginResult.rank = "FO"
     1560
     1561        gui = wizard.gui
     1562
     1563        dialog = gtk.MessageDialog(parent = gui.mainWindow,
     1564                                   type = MESSAGETYPE_INFO,
     1565                                   message_format = xstr("student_fo"))
     1566
     1567        dialog.add_button(xstr("button_ok"), RESPONSETYPE_OK)
     1568        dialog.set_title(WINDOW_TITLE_BASE)
     1569        secondary = xstr("student_fo_secondary")
     1570        dialog.format_secondary_markup(secondary)
     1571        dialog.run()
     1572        dialog.hide()
     1573
     1574        gui.reset()
    14541575
    14551576#-----------------------------------------------------------------------------
     
    15751696        self.addCancelFlightButton()
    15761697
    1577         self.addPreviousButton(clicked = self._backClicked)
     1698        self._previousButton = \
     1699          self.addPreviousButton(clicked = self._backClicked)
    15781700
    15791701        self._button = self.addButton(xstr("button_connect"), default = True,
     
    16091731            self._selectMSFS.set_active(config.defaultMSFS)
    16101732            self._selectXPlane.set_active(not config.defaultMSFS)
     1733
     1734        self._previousButton.set_sensitive(not self._wizard.entranceExam)
    16111735
    16121736    def finalize(self):
     
    21252249        alternate = self._alternate.get_text()
    21262250        self._button.set_sensitive(cruiseLevel>=50 and self._getRoute()!="" and
    2127                                    len(alternate)==4)
     2251                                   (len(alternate)==4 or self._wizard.entranceExam))
    21282252
    21292253    def _cruiseLevelChanged(self, *arg):
     
    42244348    def _forwardClicked(self, button):
    42254349        """Called when the forward button is clicked."""
    4226         aircraft = self._wizard.gui.flight.aircraft
     4350        wizard = self._wizard
     4351
     4352        aircraft = wizard.gui.flight.aircraft
    42274353        aircraft.updateVRef()
    42284354        aircraft.updateLandingAntiIce()
    4229         if self._wizard.gui.config.onlineGateSystem and \
    4230            self._wizard.loggedIn and not self._completed and \
    4231            self._wizard.bookedFlight.arrivalICAO=="LHBP" and \
    4232            not self._wizard.entranceExam:
    4233             self._wizard.getFleet(callback = self._fleetRetrieved,
    4234                                   force = True)
     4355        if wizard.gui.config.onlineGateSystem and \
     4356           wizard.loggedIn and not self._completed and \
     4357           wizard.bookedFlight.arrivalICAO=="LHBP" and \
     4358           not wizard.entranceExam:
     4359            wizard.getFleet(callback = self._fleetRetrieved, force = True)
     4360        elif wizard.entranceExam:
     4361            self._handleEntranceExamDone()
    42354362        else:
    4236             self._wizard.nextPage()
     4363            wizard.nextPage()
    42374364
    42384365    def _fleetRetrieved(self, fleet):
     
    42604387            self._updatingMETAR = False
    42614388
     4389    def _handleEntranceExamDone(self):
     4390        """Handle the end of the entrance exam.
     4391
     4392        If the there was a NO-GO fault, notify the user that exam is a failure
     4393        and take them back to the student page. Otherwise congratulate, update
     4394        the database to reflect that the exam has been taken and go back to the
     4395        student page."""
     4396        self._wizard.jumpPage("chkfinish")
     4397
     4398#-----------------------------------------------------------------------------
     4399
     4400class PIREPSaveHelper(object):
     4401    """A helper to use for saving PIREPs."""
     4402    def __init__(self, wizard):
     4403        """Construct the helper."""
     4404        super(PIREPSaveHelper, self).__init__()
     4405
     4406        self._wizard = wizard
     4407
     4408        self._lastSavePath = None
     4409        self._savePIREPDialog = None
     4410
     4411    def addButton(self, page):
     4412        """Add a button to save the PIREP to the given page."""
     4413        return page.addButton(xstr("finish_save"), sensitive = False,
     4414                              clicked = self._saveClicked,
     4415                              tooltip = xstr("finish_save_tooltip"),
     4416                              clickedArg = page)
     4417
     4418    def autoSavePIREP(self):
     4419        """Perform the automatic saving of the PIREP."""
     4420        self._lastSavePath = os.path.join(self._wizard.gui.config.pirepDirectory,
     4421                                          self._getDefaultPIREPName())
     4422        self._lastSavePath = text2unicode(self._lastSavePath)
     4423        self._savePIREP(automatic = True)
     4424
     4425    def _getDefaultPIREPName(self):
     4426        """Get the default name of the PIREP."""
     4427        gui = self._wizard.gui
     4428
     4429        bookedFlight = gui.bookedFlight
     4430        tm = time.gmtime()
     4431
     4432        pilotID = self._wizard.pilotID
     4433        if pilotID: pilotID += " "
     4434        return "%s%s %02d%02d %s-%s.pirep" % \
     4435               (pilotID, str(bookedFlight.departureTime.date()),
     4436                tm.tm_hour, tm.tm_min,
     4437                bookedFlight.departureICAO, bookedFlight.arrivalICAO)
     4438
     4439    def _saveClicked(self, button, page):
     4440        """Called when the Save PIREP button is clicked."""
     4441        gui = self._wizard.gui
     4442
     4443        fileName = self._getDefaultPIREPName()
     4444
     4445        dialog = self._getSaveDialog()
     4446
     4447        if self._lastSavePath is None:
     4448            pirepDirectory = gui.config.pirepDirectory
     4449            if pirepDirectory is not None:
     4450                dialog.set_current_folder(pirepDirectory)
     4451        else:
     4452            dialog.set_current_folder(os.path.dirname(self._lastSavePath))
     4453
     4454        dialog.set_current_name(fileName)
     4455        result = dialog.run()
     4456        dialog.hide()
     4457
     4458        if result==RESPONSETYPE_OK:
     4459            self._lastSavePath = text2unicode(dialog.get_filename())
     4460            self._savePIREP(page)
     4461
     4462    def _savePIREP(self, page, automatic = False):
     4463        """Perform the saving of the PIREP."""
     4464
     4465        gui = self._wizard.gui
     4466
     4467        if automatic:
     4468            gui.beginBusy(xstr("finish_autosave_busy"))
     4469
     4470        pirep = PIREP(gui.flight)
     4471        error = pirep.save(self._lastSavePath)
     4472
     4473        if automatic:
     4474            gui.endBusy()
     4475
     4476        if error:
     4477            type = MESSAGETYPE_ERROR
     4478            message = xstr("finish_save_failed")
     4479            secondary = xstr("finish_save_failed_sec") % (text2unicode(error),)
     4480        else:
     4481            type = MESSAGETYPE_INFO
     4482            message = xstr("finish_save_done")
     4483            if automatic:
     4484                secondary = xstr("finish_save_done_sec") % (self._lastSavePath,)
     4485            else:
     4486                secondary = None
     4487            page.setPIREPSaved()
     4488
     4489        dialog = gtk.MessageDialog(parent = gui.mainWindow,
     4490                                   type = type, message_format = message)
     4491        dialog.add_button(xstr("button_ok"), RESPONSETYPE_OK)
     4492        dialog.set_title(WINDOW_TITLE_BASE)
     4493        if secondary is not None:
     4494            dialog.format_secondary_markup(secondary)
     4495
     4496        dialog.run()
     4497        dialog.hide()
     4498
     4499        return pirepSaved
     4500
     4501    def _getSaveDialog(self):
     4502        """Get the PIREP saving dialog.
     4503
     4504        If it does not exist yet, create it."""
     4505        if self._savePIREPDialog is None:
     4506            gui = self._wizard.gui
     4507            dialog = gtk.FileChooserDialog(title = WINDOW_TITLE_BASE + " - " +
     4508                                           xstr("finish_save_title"),
     4509                                           action = FILE_CHOOSER_ACTION_SAVE,
     4510                                           buttons = (gtk.STOCK_CANCEL,
     4511                                                      RESPONSETYPE_CANCEL,
     4512                                                      gtk.STOCK_OK, RESPONSETYPE_OK),
     4513                                           parent = gui.mainWindow)
     4514            dialog.set_modal(True)
     4515            dialog.set_do_overwrite_confirmation(True)
     4516
     4517            filter = gtk.FileFilter()
     4518            filter.set_name(xstr("file_filter_pireps"))
     4519            filter.add_pattern("*.pirep")
     4520            dialog.add_filter(filter)
     4521
     4522            filter = gtk.FileFilter()
     4523            filter.set_name(xstr("file_filter_all"))
     4524            filter.add_pattern("*.*")
     4525            dialog.add_filter(filter)
     4526
     4527            self._savePIREPDialog = dialog
     4528
     4529        return self._savePIREPDialog
     4530
    42624531#-----------------------------------------------------------------------------
    42634532
     
    42694538                     ("flighttype_charter", const.FLIGHTTYPE_CHARTER) ]
    42704539
    4271     def __init__(self, wizard):
     4540    def __init__(self, wizard, saveHelper):
    42724541        """Construct the finish page."""
    42734542        help = xstr("finish_help") + xstr("finish_help_goodtime")
     
    44564725        self.addPreviousButton(clicked = self._backClicked)
    44574726
    4458         self._saveButton = self.addButton(xstr("finish_save"),
    4459                                           sensitive = False,
    4460                                           clicked = self._saveClicked,
    4461                                           tooltip = xstr("finish_save_tooltip"))
    4462         self._savePIREPDialog = None
    4463         self._lastSavePath = None
     4727        self._saveHelper = saveHelper
     4728        self._saveButton = saveHelper.addButton(self)
    44644729
    44654730        self._tooBigTimeDifference = False
     
    45614826        if gui.config.pirepAutoSave and sensitive and not wasSensitive:
    45624827            if gui.isWizardActive():
    4563                 self._autoSavePIREP()
     4828                self._saveHelper.autoSavePIREP()
    45644829            else:
    45654830                self._deferredAutoSave = True
     
    45764841        super(FinishPage, self).grabDefault()
    45774842        if self._deferredAutoSave:
    4578             self._autoSavePIREP()
     4843            self._saveHelper.autoSavePIREP()
    45794844            self._deferredAutoSave = False
    45804845
    4581     def _autoSavePIREP(self):
    4582         """Perform the automatic saving of the PIREP."""
    4583         self._lastSavePath = os.path.join(self._wizard.gui.config.pirepDirectory,
    4584                                           self._getDefaultPIREPName())
    4585         self._lastSavePath = text2unicode(self._lastSavePath)
    4586         self._savePIREP(automatic = True)
     4846    def setPIREPSaved(self):
     4847        """Mark the PIREP as saved."""
     4848        self._pirepSaved = True
    45874849
    45884850    def _backClicked(self, button):
     
    46164878
    46174879        gui.reset()
    4618 
    4619     def _getDefaultPIREPName(self):
    4620         """Get the default name of the PIREP."""
    4621         gui = self._wizard.gui
    4622 
    4623         bookedFlight = gui.bookedFlight
    4624         tm = time.gmtime()
    4625 
    4626         pilotID = self._wizard.pilotID
    4627         if pilotID: pilotID += " "
    4628         return "%s%s %02d%02d %s-%s.pirep" % \
    4629                (pilotID, str(bookedFlight.departureTime.date()),
    4630                 tm.tm_hour, tm.tm_min,
    4631                 bookedFlight.departureICAO, bookedFlight.arrivalICAO)
    4632 
    4633 
    4634     def _saveClicked(self, button):
    4635         """Called when the Save PIREP button is clicked."""
    4636         gui = self._wizard.gui
    4637 
    4638         fileName = self._getDefaultPIREPName()
    4639 
    4640         dialog = self._getSaveDialog()
    4641 
    4642         if self._lastSavePath is None:
    4643             pirepDirectory = gui.config.pirepDirectory
    4644             if pirepDirectory is not None:
    4645                 dialog.set_current_folder(pirepDirectory)
    4646         else:
    4647             dialog.set_current_folder(os.path.dirname(self._lastSavePath))
    4648 
    4649         dialog.set_current_name(fileName)
    4650         result = dialog.run()
    4651         dialog.hide()
    4652 
    4653         if result==RESPONSETYPE_OK:
    4654             self._lastSavePath = text2unicode(dialog.get_filename())
    4655             self._savePIREP()
    4656 
    4657     def _savePIREP(self, automatic = False):
    4658         """Perform the saving of the PIREP."""
    4659 
    4660         gui = self._wizard.gui
    4661 
    4662         if automatic:
    4663             gui.beginBusy(xstr("finish_autosave_busy"))
    4664 
    4665         pirep = PIREP(gui.flight)
    4666         error = pirep.save(self._lastSavePath)
    4667 
    4668         if automatic:
    4669             gui.endBusy()
    4670 
    4671         if error:
    4672             type = MESSAGETYPE_ERROR
    4673             message = xstr("finish_save_failed")
    4674             secondary = xstr("finish_save_failed_sec") % (text2unicode(error),)
    4675         else:
    4676             type = MESSAGETYPE_INFO
    4677             message = xstr("finish_save_done")
    4678             if automatic:
    4679                 secondary = xstr("finish_save_done_sec") % (self._lastSavePath,)
    4680             else:
    4681                 secondary = None
    4682             self._pirepSaved = True
    4683 
    4684         dialog = gtk.MessageDialog(parent = gui.mainWindow,
    4685                                    type = type, message_format = message)
    4686         dialog.add_button(xstr("button_ok"), RESPONSETYPE_OK)
    4687         dialog.set_title(WINDOW_TITLE_BASE)
    4688         if secondary is not None:
    4689             dialog.format_secondary_markup(secondary)
    4690 
    4691         dialog.run()
    4692         dialog.hide()
    4693 
    4694     def _getSaveDialog(self):
    4695         """Get the PIREP saving dialog.
    4696 
    4697         If it does not exist yet, create it."""
    4698         if self._savePIREPDialog is None:
    4699             gui = self._wizard.gui
    4700             dialog = gtk.FileChooserDialog(title = WINDOW_TITLE_BASE + " - " +
    4701                                            xstr("finish_save_title"),
    4702                                            action = FILE_CHOOSER_ACTION_SAVE,
    4703                                            buttons = (gtk.STOCK_CANCEL,
    4704                                                       RESPONSETYPE_CANCEL,
    4705                                                       gtk.STOCK_OK, RESPONSETYPE_OK),
    4706                                            parent = gui.mainWindow)
    4707             dialog.set_modal(True)
    4708             dialog.set_do_overwrite_confirmation(True)
    4709 
    4710             filter = gtk.FileFilter()
    4711             filter.set_name(xstr("file_filter_pireps"))
    4712             filter.add_pattern("*.pirep")
    4713             dialog.add_filter(filter)
    4714 
    4715             filter = gtk.FileFilter()
    4716             filter.set_name(xstr("file_filter_all"))
    4717             filter.add_pattern("*.*")
    4718             dialog.add_filter(filter)
    4719 
    4720             self._savePIREPDialog = dialog
    4721 
    4722         return self._savePIREPDialog
    4723 
    47244880
    47254881    def _sendClicked(self, button):
     
    48164972#-----------------------------------------------------------------------------
    48174973
     4974class CheckFlightFinishPage(Page):
     4975    """Finish page for a check flight."""
     4976    def __init__(self, wizard, saveHelper):
     4977        """Construct the check flight finish page."""
     4978        super(CheckFlightFinishPage, self).__init__(wizard,
     4979                                                    "chkfinish",
     4980                                                    xstr("chkfinish_title"),
     4981                                                    "")
     4982
     4983        alignment = gtk.Alignment(xalign = 0.5, yalign = 0.5,
     4984                                  xscale = 1.0, yscale = 1.0)
     4985        self._label = gtk.Label()
     4986        alignment.add(self._label)
     4987
     4988        self.setMainWidget(alignment)
     4989
     4990        self._saveHelper = saveHelper
     4991        self._saveButton = saveHelper.addButton(self)
     4992
     4993        self._button = self.addNextButton(sensitive = False,
     4994                                          clicked =  self._forwardClicked)
     4995
     4996    def activate(self):
     4997        """Activate the page."""
     4998        wizard = self._wizard
     4999        loginResult = wizard.loginResult
     5000        gui = wizard.gui
     5001        rating = gui.flight.logger.getRating()
     5002
     5003        if rating>=0:
     5004            loginResult.checkFlightStatus = True
     5005
     5006        firstOfficer = \
     5007          loginResult.entryExamPassed and loginResult.checkFlightStatus
     5008
     5009        if firstOfficer:
     5010            loginResult.rank = "FO"
     5011
     5012        if rating<0:
     5013            mainMessage = xstr("chkfinish_failed")
     5014        else:
     5015            mainMessage = xstr("chkfinish_passed_begin")
     5016            if firstOfficer:
     5017                mainMessage += xstr("chkfinish_passed_fo")
     5018            mainMessage += xstr("chkfinish_passed_end")
     5019
     5020        if firstOfficer:
     5021            nextMessage = xstr("chkfinish_next")
     5022        else:
     5023            nextMessage = xstr("chkfinish_next_student_begin")
     5024            if not loginResult.entryExamPassed and \
     5025               not loginResult.checkFlightStatus:
     5026                nextMessage += xstr("chkfinish_next_student_nothing")
     5027            elif loginResult.entryExamPassed and \
     5028                 not loginResult.checkFlightStatus:
     5029                nextMessage += xstr("chkfinish_next_student_no_flight")
     5030            elif not loginResult.entryExamPassed and \
     5031                 loginResult.checkFlightStatus:
     5032                nextMessage += xstr("chkfinish_next_student_no_exam")
     5033
     5034        self._label.set_text(mainMessage +
     5035                             xstr("chkfinish_savepirep") +
     5036                             nextMessage)
     5037        self._label.set_use_markup(True)
     5038        self._label.set_alignment(0.5, 0.0)
     5039
     5040        self._saveButton.set_sensitive(True)
     5041        self._button.set_sensitive(True)
     5042
     5043    def _forwardClicked(self, button):
     5044        """Jump to the student page if there are some tasks to do,
     5045        or to the flight selection page, if the pilot is allowed to perform
     5046        MAVA flights."""
     5047        wizard = self._wizard
     5048        gui = wizard.gui
     5049
     5050        loginResult = wizard.loginResult
     5051        if loginResult.checkFlightStatus:
     5052            gui.beginBusy(xstr("chkfinish_updateweb_busy"))
     5053            gui.webHandler.setCheckFlightPassed(self._checkFlightPassedSetCallback,
     5054                                                wizard.checkFlightAircraftType)
     5055        else:
     5056            self._resetGUI()
     5057
     5058    def _checkFlightPassedSetCallback(self, returned, result):
     5059        """Called when the check flight status has been set."""
     5060        gobject.idle_add(self._checkFlightPassedSet, returned, result)
     5061
     5062    def _checkFlightPassedSet(self, returned, result):
     5063        """Handle the result of an attempt to set the check flight status."""
     5064        gui = self._wizard.gui
     5065
     5066        gui.endBusy()
     5067
     5068        if returned:
     5069            self._resetGUI()
     5070        else:
     5071            dialog = gtk.MessageDialog(parent = gui.mainWindow,
     5072                                       type = MESSAGETYPE_ERROR,
     5073                                       message_format =
     5074                                       xstr("chkfinish_passedset_failed"))
     5075            dialog.set_title(WINDOW_TITLE_BASE + " - " +
     5076                             xstr("chkfinish_passedset_failed_title"))
     5077            dialog.format_secondary_markup(xstr("chkfinish_passedset_failed_secondary"))
     5078
     5079            dialog.add_button(xstr("button_ok"), 0)
     5080
     5081            dialog.run()
     5082            dialog.hide()
     5083
     5084    def _resetGUI(self):
     5085        """Reset the GUI."""
     5086        gui = self._wizard.gui
     5087        gui.reset()
     5088
     5089#-----------------------------------------------------------------------------
     5090
    48185091class Wizard(gtk.VBox):
    48195092    """The flight wizard."""
     
    48325105        self._pages.append(GateSelectionPage(self))
    48335106        self._pages.append(RegisterPage(self))
    4834         self._pages.append(StudentPage(self))
     5107        self._studentPage = StudentPage(self)
     5108        self._pages.append(self._studentPage)
    48355109        self._pages.append(ConnectPage(self))
    48365110        self._payloadPage = PayloadPage(self)
     
    48565130        self._landingPage = LandingPage(self)
    48575131        self._pages.append(self._landingPage)
    4858         self._finishPage = FinishPage(self)
     5132
     5133        pirepSaveHelper = PIREPSaveHelper(self)
     5134
     5135        self._finishPage = FinishPage(self, pirepSaveHelper)
    48595136        self._pages.append(self._finishPage)
     5137        self._pages.append(CheckFlightFinishPage(self, pirepSaveHelper))
    48605138
    48615139        self._requestedWidth = None
     
    49165194        """Get the login result."""
    49175195        return self._loginResult
     5196
     5197    @property
     5198    def checkFlightAircraftType(self):
     5199        """Get the type of the aircraft used to perform the check flight."""
     5200        return self._studentPage.aircraftType
    49185201
    49195202    def setCurrentPage(self, index, finalize = False, fromPageShift = None):
     
    52185501    def reloadFlights(self, callback):
    52195502        """Reload the flights from the MAVA server."""
    5220         self.login(callback, None, None, None)
     5503        self.login(callback, None, None)
     5504
     5505    def cancelFlight(self, reloadCallback):
     5506        """Cancel the flight.
     5507
     5508        If it is an entry exam flight, we go back to the student page.
     5509        Otherwise we reload the flights."""
     5510        if self.entranceExam:
     5511            self.reset(None)
     5512            self.jumpPage("student")
     5513        else:
     5514            self.reloadFlights(reloadCallback)
    52215515
    52225516    def cruiseLevelChanged(self):
  • src/mlx/gui/gui.py

    r755 r769  
    581581
    582582        if self.loggedIn:
    583             self._wizard.reloadFlights(self._handleReloadResult)
     583            self._wizard.cancelFlight(self._handleReloadResult)
    584584        else:
    585585            self._wizard.reset(None)
  • src/mlx/rpc.py

    r764 r769  
    262262                                  self._server.getEntryExamStatus(sessionID))
    263263        return (value["entryExamPassed"], value["entryExamLink"],
    264                 value["checkFlightStatus"])
     264                value["checkFlightStatus"], value["madeFO"])
    265265
    266266    def getFleet(self):
     
    292292        self._performCall(lambda sessionID:
    293293                          self._server.updateOnlineACARS(sessionID, acars))
     294
     295    def setCheckFlightPassed(self, type):
     296        """Mark the check flight of the user passed with the given type."""
     297        self._performCall(lambda sessionID:
     298                          self._server.setCheckFlightPassed(sessionID, type))
    294299
    295300    def _performCall(self, callFn, acceptResults = []):
  • src/mlx/web.py

    r764 r769  
    9191                      const.AIRCRAFT_B462  : "146" }
    9292
     93    checkFlightTypes = [ const.AIRCRAFT_B736, const.AIRCRAFT_B737,
     94                         const.AIRCRAFT_B738, const.AIRCRAFT_DH8D ]
     95
    9396    @staticmethod
    9497    def getDateTime(date, time):
     
    9699        return datetime.datetime.strptime(date + " " + time,
    97100                                          "%Y-%m-%d %H:%M:%S")
     101
     102    @staticmethod
     103    def forCheckFlight(aircraftType):
     104        """Create a booked flight for a check flight with the given aircraft
     105        type."""
     106        flight = BookedFlight()
     107
     108        flight.departureICAO = "LHBP"
     109        flight.arrivalICAO = "LHBP"
     110
     111        flight.aircraftType = aircraftType
     112        flight.aircraftTypeName = BookedFlight.TYPE2TYPECODE[aircraftType]
     113
     114        # FIXME: perhaps find one for the type
     115        flight.tailNumber = "HA-CHK"
     116        flight.callsign = "HA-CHK"
     117
     118        flight.numPassengers = 0
     119        flight.numCrew = 2
     120        flight.bagWeight = 0
     121        flight.cargoWeight = 0
     122        flight.mailWeight = 0
     123        flight.route = "DCT"
     124
     125        t = datetime.datetime.now() + datetime.timedelta(minutes = 20)
     126        flight.departureTime = datetime.datetime(t.year, t.month, t.day,
     127                                                 t.hour, t.minute)
     128        t = flight.departureTime + datetime.timedelta(minutes = 30)
     129        flight.arrivalTime = datetime.datetime(t.year, t.month, t.day,
     130                                               t.hour, t.minute)
     131
     132        return flight
    98133
    99134    def __init__(self, id = None):
     
    741776                result.entryExamLink = reply[1]
    742777                result.checkFlightStatus = reply[2]
     778                if reply[3]:
     779                    result.rank = "FO"
    743780
    744781        return result
     
    761798        result.entryExamLink = reply[1]
    762799        result.checkFlightStatus = reply[2]
     800        result.madeFO = reply[3]
    763801
    764802        return result
     
    11561194#------------------------------------------------------------------------------
    11571195
     1196class SetCheckFlightPassed(RPCRequest):
     1197    """A request to mark the user as one having passed the check flight."""
     1198    def __init__(self, client, callback, aircraftType):
     1199        """Construct the request for the given type."""
     1200        super(SetCheckFlightPassed, self).__init__(client, callback)
     1201        self._aircraftType = aircraftType
     1202
     1203    def run(self):
     1204        """Perform the update."""
     1205        aircraftType = BookedFlight.TYPE2TYPECODE[self._aircraftType]
     1206        self._client.setCheckFlightPassed(aircraftType)
     1207        return Result()
     1208
     1209#------------------------------------------------------------------------------
     1210
    11581211class Handler(threading.Thread):
    11591212    """The handler for the web services.
     
    12321285        self._addRequest(SendBugReport(callback, summary, description, email))
    12331286
     1287    def setCheckFlightPassed(self, callback, aircraftType):
     1288        """Mark the check flight as passed."""
     1289        self._addRequest(SetCheckFlightPassed(self._rpcClient,
     1290                                              callback, aircraftType))
     1291
    12341292    def run(self):
    12351293        """Process the requests."""
Note: See TracChangeset for help on using the changeset viewer.