Changeset 769:d10b450fff75
- Timestamp:
- 04/24/16 12:50:26 (9 years ago)
- Branch:
- default
- Phase:
- public
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
locale/en/mlx.po
r764 r769 1 # English-language texts for the MAVA Logger X 1 2 2 # 3 3 # István Váradi <ivaradi@gmail.com>, 2012 … … 2311 2311 "the exam earlier. Note, that its status is updated only a few minutes " 2312 2312 "after passing the exam." 2313 2314 msgid "student_check_flight_status" 2315 msgstr "Check flight:" 2316 2317 msgid "student_check_flight_passed" 2318 msgstr "<span color=\"darkgreen\"><b>Passed</b></span>" 2319 2320 msgid "student_check_flight_not_passed" 2321 msgstr "<span color=\"orange\"><b>Not yet passed</b></span>" 2322 2323 msgid "student_check_flight" 2324 msgstr "Perform the _check flight" 2325 2326 msgid "student_check_flight_tooltip" 2327 msgstr "" 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 2333 msgid "student_fo" 2334 msgstr "Congratulations!" 2335 2336 msgid "student_fo_secondary" 2337 msgstr "" 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 2342 msgid "chkfinish_title" 2343 msgstr "Check flight finished" 2344 2345 msgid "chkfinish_passed_begin" 2346 msgstr "" 2347 "<b><span size=\"xx-large\">Congratulations!</span></b>\n" 2348 "\n" 2349 "You have successfully completed your check flight." 2350 2351 msgid "chkfinish_passed_fo" 2352 msgstr "" 2353 " \n\n" 2354 "You have received the rank of <b>First Officer</b> (FO)." 2355 2356 msgid "chkfinish_passed_end" 2357 msgstr "" 2358 " \n\n" 2359 "You may wish to review the log if you have made any mistakes." 2360 2361 msgid "chkfinish_failed" 2362 msgstr "" 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 2367 msgid "chkfinish_savepirep" 2368 msgstr "" 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 2374 msgid "chkfinish_next_student_begin" 2375 msgstr "" 2376 " \n\n" 2377 "The <i>Next</i> button takes you back to the <i>Student</i> page," 2378 2379 msgid "chkfinish_next_student_nothing" 2380 msgstr "" 2381 " \n" 2382 "where you can initiate another test flight or take your entry exam." 2383 2384 msgid "chkfinish_next_student_no_exam" 2385 msgstr "" 2386 " \n" 2387 "where you can take your entry exam." 2388 2389 msgid "chkfinish_next_student_no_flight" 2390 msgstr "" 2391 " \n" 2392 "where you can initiate another test flight." 2393 2394 msgid "chkfinish_next" 2395 msgstr "" 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 2400 msgid "chkfinish_updateweb_busy" 2401 msgstr "Updating check flight status..." 2402 2403 msgid "chkfinish_passedset_failed" 2404 msgstr "Failed to update the check flight status" 2405 2406 msgid "chkfinish_passedset_failed_title" 2407 msgstr "Update failure" 2408 2409 msgid "chkfinish_passedset_failed_secondary" 2410 msgstr "" 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 781 781 msgstr "Emelke_dési profil:" 782 782 783 msgid "simbrief_climb_profile_too tip"783 msgid "simbrief_climb_profile_tooltip" 784 784 msgstr "Válaszd ki az emelkedési profilt" 785 785 … … 787 787 msgstr "_Utazó profil:" 788 788 789 msgid "simbrief_cruise_profile_too tip"789 msgid "simbrief_cruise_profile_tooltip" 790 790 msgstr "Válaszd ki az utazó profilt" 791 791 … … 793 793 msgstr "Süll_yedési profil:" 794 794 795 msgid "simbrief_descent_profile_too tip"795 msgid "simbrief_descent_profile_tooltip" 796 796 msgstr "Válaszd ki a süllyedési profilt" 797 797 … … 2254 2254 msgstr "" 2255 2255 "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" 2257 2257 "\n" 2258 2258 "Pilóta azonosítód: <b>%s</b>.\n" 2259 2259 "\n" 2260 "Most a tanulók oldala fog megjelenni,\n"2260 "Most a jelöltek oldala fog megjelenni,\n" 2261 2261 "ahol kezdeményezheted a belépő teszt\n" 2262 2262 "kitöltését vagy elindíthatod az ellenőrző\n" 2263 2263 "repülést.\n" 2264 2264 "\n" 2265 "A tanulók oldalára bármikor visszatérhetsz\n"2265 "A jelöltek oldalára bármikor visszatérhetsz\n" 2266 2266 "ha elindítod a programot és bejelentkezel." 2267 2267 … … 2269 2269 msgstr "" 2270 2270 "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" 2272 2272 "\n" 2273 2273 "Pilóta azonosítód: <b>%s</b>.\n" … … 2300 2300 2301 2301 msgid "student_title" 2302 msgstr " Tanuló"2302 msgstr "Jelölt" 2303 2303 2304 2304 msgid "student_help" … … 2327 2327 "Ha a gomb inaktív, a vizsgát korábban már sikeresen teljesítetted. " 2328 2328 "A gomb állapota csak néhány perccel a vizsga teljesítése után frissül." 2329 2330 msgid "student_check_flight_status" 2331 msgstr "Ellenőrző repülés:" 2332 2333 msgid "student_check_flight_passed" 2334 msgstr "<span color=\"darkgreen\"><b>Sikeres</b></span>" 2335 2336 msgid "student_check_flight_not_passed" 2337 msgstr "<span color=\"orange\"><b>Még nem hajtottad végre</b></span>" 2338 2339 msgid "student_check_flight" 2340 msgstr "Ellenőrző _repülés" 2341 2342 msgid "student_check_flight_tooltip" 2343 msgstr "" 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 2349 msgid "student_fo" 2350 msgstr "Gratulálunk!" 2351 2352 msgid "student_fo_secondary" 2353 msgstr "" 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 2358 msgid "chkfinish_title" 2359 msgstr "Az ellenőrző repülés vége" 2360 2361 msgid "chkfinish_passed_begin" 2362 msgstr "" 2363 "<b><span size=\"xx-large\">Gratulálunk!</span></b>\n" 2364 "\n" 2365 "Sikeresen teljesítetted az ellenőrző repülést." 2366 2367 msgid "chkfinish_passed_fo" 2368 msgstr "" 2369 " \n\n" 2370 "A rangod <b>első tiszt</b> (FO) lett." 2371 2372 msgid "chkfinish_passed_end" 2373 msgstr "" 2374 " \n\n" 2375 "Ha kívánod, a naplóban megnézheted, hogy vétettél-e valamilyen hibát." 2376 2377 msgid "chkfinish_failed" 2378 msgstr "" 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 2383 msgid "chkfinish_savepirep" 2384 msgstr "" 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 2390 msgid "chkfinish_next_student_begin" 2391 msgstr "" 2392 " \n\n" 2393 "Az <i>Előre</i> gomb visszavisz a <i>Jelölt</i> oldalra," 2394 2395 msgid "chkfinish_next_student_nothing" 2396 msgstr "" 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 2401 msgid "chkfinish_next_student_no_exam" 2402 msgstr "" 2403 " \n" 2404 "ahol kezdeményezheted az elméleti vizsga letételét." 2405 2406 msgid "chkfinish_next_student_no_flight" 2407 msgstr "" 2408 " \n" 2409 "ahol egy újabb ellenőrző repülést kezdeményezhetsz." 2410 2411 msgid "chkfinish_next" 2412 msgstr "" 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 2417 msgid "chkfinish_updateweb_busy" 2418 msgstr "Az ellenőrző repülés státuszának frissítése..." 2419 2420 msgid "chkfinish_passedset_failed" 2421 msgstr "Nem sikerült frissíteni az ellenőrző repülés státuszát" 2422 2423 msgid "chkfinish_passedset_failed_title" 2424 msgstr "Frissítési hiba" 2425 2426 msgid "chkfinish_passedset_failed_secondary" 2427 msgstr "" 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 169 169 170 170 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): 172 173 """Add a button with the given label. 173 174 … … 183 184 button.set_tooltip_text(tooltip) 184 185 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) 186 190 return button 187 191 … … 1376 1380 xstr("student_help")) 1377 1381 1382 1383 self._getEntryExamStatusCancelled = False 1384 1378 1385 alignment = gtk.Alignment(xalign = 0.5, yalign = 0.5, 1379 1386 xscale = 0.5, yscale = 0.0) 1380 1387 1381 table = gtk.Table( 2, 2)1388 table = gtk.Table(6, 4) 1382 1389 table.set_row_spacings(4) 1383 table.set_col_spacings( 32)1390 table.set_col_spacings(0) 1384 1391 table.set_homogeneous(False) 1385 1392 alignment.add(table) … … 1391 1398 xscale=0.0, yscale = 0.0) 1392 1399 label = gtk.Label(xstr("student_entry_exam_status")) 1400 label.set_alignment(0.0, 0.5) 1393 1401 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) 1395 1404 1396 1405 alignment = gtk.Alignment(xalign=0.0, yalign = 0.5, … … 1400 1409 self._entryExamStatus.set_alignment(0.0, 0.5) 1401 1410 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) 1403 1413 1404 1414 row += 1 … … 1411 1421 1412 1422 buttonAlignment.add(button) 1413 table.attach(buttonAlignment, 0, 2, row, row + 1,1423 table.attach(buttonAlignment, 0, 4, row, row + 1, xoptions = FILL, 1414 1424 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] 1415 1484 1416 1485 def activate(self): 1417 1486 """Activate the student page.""" 1487 print "StudentPage.activate" 1488 self._getEntryExamStatusCancelled = False 1489 1418 1490 loginResult = self._wizard.loginResult 1419 1491 self._entryExamLink = loginResult.entryExamLink 1420 1492 1421 1493 self._updateEntryExamStatus(loginResult.entryExamPassed) 1422 1423 1494 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 1424 1503 1425 1504 def _entryExamClicked(self, button): … … 1429 1508 def _getEntryExamStatus(self): 1430 1509 """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)) 1434 1514 1435 1515 def _entryExamStatusCallback(self, returned, result): … … 1440 1520 """Called when the entry exam status is availabe.""" 1441 1521 print "_handleEntryExamStatus", returned, result 1442 if returned :1522 if returned and not self._getEntryExamStatusCancelled: 1443 1523 self._entryExamLink = result.entryExamLink 1444 1524 self._updateEntryExamStatus(result.entryExamPassed) 1445 self._getEntryExamStatus() 1525 if result.madeFO: 1526 self._madeFO() 1527 else: 1528 self._getEntryExamStatus() 1446 1529 1447 1530 def _updateEntryExamStatus(self, passed): … … 1452 1535 self._entryExamStatus.set_use_markup(True) 1453 1536 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() 1454 1575 1455 1576 #----------------------------------------------------------------------------- … … 1575 1696 self.addCancelFlightButton() 1576 1697 1577 self.addPreviousButton(clicked = self._backClicked) 1698 self._previousButton = \ 1699 self.addPreviousButton(clicked = self._backClicked) 1578 1700 1579 1701 self._button = self.addButton(xstr("button_connect"), default = True, … … 1609 1731 self._selectMSFS.set_active(config.defaultMSFS) 1610 1732 self._selectXPlane.set_active(not config.defaultMSFS) 1733 1734 self._previousButton.set_sensitive(not self._wizard.entranceExam) 1611 1735 1612 1736 def finalize(self): … … 2125 2249 alternate = self._alternate.get_text() 2126 2250 self._button.set_sensitive(cruiseLevel>=50 and self._getRoute()!="" and 2127 len(alternate)==4)2251 (len(alternate)==4 or self._wizard.entranceExam)) 2128 2252 2129 2253 def _cruiseLevelChanged(self, *arg): … … 4224 4348 def _forwardClicked(self, button): 4225 4349 """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 4227 4353 aircraft.updateVRef() 4228 4354 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() 4235 4362 else: 4236 self._wizard.nextPage()4363 wizard.nextPage() 4237 4364 4238 4365 def _fleetRetrieved(self, fleet): … … 4260 4387 self._updatingMETAR = False 4261 4388 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 4400 class 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 4262 4531 #----------------------------------------------------------------------------- 4263 4532 … … 4269 4538 ("flighttype_charter", const.FLIGHTTYPE_CHARTER) ] 4270 4539 4271 def __init__(self, wizard ):4540 def __init__(self, wizard, saveHelper): 4272 4541 """Construct the finish page.""" 4273 4542 help = xstr("finish_help") + xstr("finish_help_goodtime") … … 4456 4725 self.addPreviousButton(clicked = self._backClicked) 4457 4726 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) 4464 4729 4465 4730 self._tooBigTimeDifference = False … … 4561 4826 if gui.config.pirepAutoSave and sensitive and not wasSensitive: 4562 4827 if gui.isWizardActive(): 4563 self._ autoSavePIREP()4828 self._saveHelper.autoSavePIREP() 4564 4829 else: 4565 4830 self._deferredAutoSave = True … … 4576 4841 super(FinishPage, self).grabDefault() 4577 4842 if self._deferredAutoSave: 4578 self._ autoSavePIREP()4843 self._saveHelper.autoSavePIREP() 4579 4844 self._deferredAutoSave = False 4580 4845 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 4587 4849 4588 4850 def _backClicked(self, button): … … 4616 4878 4617 4879 gui.reset() 4618 4619 def _getDefaultPIREPName(self):4620 """Get the default name of the PIREP."""4621 gui = self._wizard.gui4622 4623 bookedFlight = gui.bookedFlight4624 tm = time.gmtime()4625 4626 pilotID = self._wizard.pilotID4627 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.gui4637 4638 fileName = self._getDefaultPIREPName()4639 4640 dialog = self._getSaveDialog()4641 4642 if self._lastSavePath is None:4643 pirepDirectory = gui.config.pirepDirectory4644 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.gui4661 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_ERROR4673 message = xstr("finish_save_failed")4674 secondary = xstr("finish_save_failed_sec") % (text2unicode(error),)4675 else:4676 type = MESSAGETYPE_INFO4677 message = xstr("finish_save_done")4678 if automatic:4679 secondary = xstr("finish_save_done_sec") % (self._lastSavePath,)4680 else:4681 secondary = None4682 self._pirepSaved = True4683 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.gui4700 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 = dialog4721 4722 return self._savePIREPDialog4723 4724 4880 4725 4881 def _sendClicked(self, button): … … 4816 4972 #----------------------------------------------------------------------------- 4817 4973 4974 class 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 4818 5091 class Wizard(gtk.VBox): 4819 5092 """The flight wizard.""" … … 4832 5105 self._pages.append(GateSelectionPage(self)) 4833 5106 self._pages.append(RegisterPage(self)) 4834 self._pages.append(StudentPage(self)) 5107 self._studentPage = StudentPage(self) 5108 self._pages.append(self._studentPage) 4835 5109 self._pages.append(ConnectPage(self)) 4836 5110 self._payloadPage = PayloadPage(self) … … 4856 5130 self._landingPage = LandingPage(self) 4857 5131 self._pages.append(self._landingPage) 4858 self._finishPage = FinishPage(self) 5132 5133 pirepSaveHelper = PIREPSaveHelper(self) 5134 5135 self._finishPage = FinishPage(self, pirepSaveHelper) 4859 5136 self._pages.append(self._finishPage) 5137 self._pages.append(CheckFlightFinishPage(self, pirepSaveHelper)) 4860 5138 4861 5139 self._requestedWidth = None … … 4916 5194 """Get the login result.""" 4917 5195 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 4918 5201 4919 5202 def setCurrentPage(self, index, finalize = False, fromPageShift = None): … … 5218 5501 def reloadFlights(self, callback): 5219 5502 """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) 5221 5515 5222 5516 def cruiseLevelChanged(self): -
src/mlx/gui/gui.py
r755 r769 581 581 582 582 if self.loggedIn: 583 self._wizard. reloadFlights(self._handleReloadResult)583 self._wizard.cancelFlight(self._handleReloadResult) 584 584 else: 585 585 self._wizard.reset(None) -
src/mlx/rpc.py
r764 r769 262 262 self._server.getEntryExamStatus(sessionID)) 263 263 return (value["entryExamPassed"], value["entryExamLink"], 264 value["checkFlightStatus"] )264 value["checkFlightStatus"], value["madeFO"]) 265 265 266 266 def getFleet(self): … … 292 292 self._performCall(lambda sessionID: 293 293 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)) 294 299 295 300 def _performCall(self, callFn, acceptResults = []): -
src/mlx/web.py
r764 r769 91 91 const.AIRCRAFT_B462 : "146" } 92 92 93 checkFlightTypes = [ const.AIRCRAFT_B736, const.AIRCRAFT_B737, 94 const.AIRCRAFT_B738, const.AIRCRAFT_DH8D ] 95 93 96 @staticmethod 94 97 def getDateTime(date, time): … … 96 99 return datetime.datetime.strptime(date + " " + time, 97 100 "%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 98 133 99 134 def __init__(self, id = None): … … 741 776 result.entryExamLink = reply[1] 742 777 result.checkFlightStatus = reply[2] 778 if reply[3]: 779 result.rank = "FO" 743 780 744 781 return result … … 761 798 result.entryExamLink = reply[1] 762 799 result.checkFlightStatus = reply[2] 800 result.madeFO = reply[3] 763 801 764 802 return result … … 1156 1194 #------------------------------------------------------------------------------ 1157 1195 1196 class 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 1158 1211 class Handler(threading.Thread): 1159 1212 """The handler for the web services. … … 1232 1285 self._addRequest(SendBugReport(callback, summary, description, email)) 1233 1286 1287 def setCheckFlightPassed(self, callback, aircraftType): 1288 """Mark the check flight as passed.""" 1289 self._addRequest(SetCheckFlightPassed(self._rpcClient, 1290 callback, aircraftType)) 1291 1234 1292 def run(self): 1235 1293 """Process the requests."""
Note:
See TracChangeset
for help on using the changeset viewer.