Changeset 756:673a9809df08 for src/mlx/gui
- Timestamp:
- 01/11/16 15:56:23 (9 years ago)
- Branch:
- default
- Phase:
- public
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/mlx/gui/flight.py
r754 r756 1127 1127 self._updateButtons() 1128 1128 1129 @property 1130 def name(self): 1131 """Get the name entered.""" 1132 return self._name.get_text() 1133 1134 @property 1135 def yearOfBirth(self): 1136 """Get the year of birth.""" 1137 yearOfBirthText = self._yearOfBirth.get_text() 1138 return int(yearOfBirthText) if yearOfBirthText else 0 1139 1140 @property 1141 def emailAddress(self): 1142 """Get the e-mail address.""" 1143 return self._emailAddress.get_text() 1144 1145 @property 1146 def emailAddressPublic(self): 1147 """Get the whether the e-mail address is public.""" 1148 return self._emailAddressPublic.get_active() 1149 1150 @property 1151 def vatsimID(self): 1152 """Get the VATSIM ID.""" 1153 return self._vatsimID.get_int() 1154 1155 @property 1156 def ivaoID(self): 1157 """Get the IVAO ID.""" 1158 return self._ivaoID.get_int() 1159 1160 @property 1161 def phoneNumber(self): 1162 """Get the phone number.""" 1163 return self._phoneNumber.get_text() 1164 1165 @property 1166 def nationality(self): 1167 """Get the nationality.""" 1168 return self._nationality.get_text() 1169 1170 @property 1171 def password(self): 1172 """Get the password.""" 1173 return self._password.get_text() 1174 1175 @property 1176 def rememberPassword(self): 1177 """Get whether the password should be remembered.""" 1178 return self._rememberButton.get_active() 1179 1129 1180 def activate(self): 1130 1181 """Setup the route from the booked flight.""" … … 1135 1186 def _updateButtons(self, widget = None): 1136 1187 """Update the sensitive state of the buttons""" 1137 name = self. _name.get_text()1188 name = self.name 1138 1189 nameLength = len(name) 1139 1190 nameSpacePosition = name.find(" ") 1140 1191 1141 yearOfBirthText = self._yearOfBirth.get_text() 1142 yearOfBirth = int(yearOfBirthText) if yearOfBirthText else 0 1143 1144 emailAddressText = self._emailAddress.get_text() 1145 emailAddressMatch = RegisterPage._emailAddressRE.match(emailAddressText) 1146 1147 vatsimID = self._vatsimID.get_int() 1148 ivaoID = self._ivaoID.get_int() 1149 1150 password = self._password.get_text() 1192 yearOfBirth = self.yearOfBirth 1193 1194 emailAddress = self.emailAddress 1195 emailAddressMatch = RegisterPage._emailAddressRE.match(emailAddress) 1196 1197 vatsimID = self.vatsimID 1198 ivaoID = self.ivaoID 1199 1200 password = self.password 1151 1201 password2 = self._password2.get_text() 1152 1202 if not password: … … 1183 1233 def _registerClicked(self, button): 1184 1234 """Called when the Register button is clicked.""" 1235 registrationData = web.Registration(self.name, self.yearOfBirth, 1236 self.emailAddress, 1237 self.emailAddressPublic, 1238 self.vatsimID, self.ivaoID, 1239 self.phoneNumber, self.nationality, 1240 self.password) 1241 print "Registering with data:" 1242 print " name:", self.name, registrationData.name 1243 print " yearOfBirth:", self.yearOfBirth, registrationData.yearOfBirth 1244 print " emailAddress:", self.emailAddress, registrationData.emailAddress 1245 print " emailAddressPublic:", self.emailAddressPublic, registrationData.emailAddressPublic 1246 print " vatsimID:", self.vatsimID, registrationData.vatsimID 1247 print " ivaoID:", self.ivaoID, registrationData.ivaoID 1248 print " phoneNumber:", self.phoneNumber, registrationData.phoneNumber 1249 print " nationality:", self.nationality, registrationData.nationality 1250 1251 gui = self._wizard.gui 1252 gui.beginBusy(xstr("register_busy")) 1253 gui.webHandler.register(self._registerResultCallback, registrationData) 1254 1255 def _registerResultCallback(self, returned, result): 1256 """Called when the registration result is available.""" 1257 gobject.idle_add(self._handleRegisterResult, returned, result) 1258 1259 def _handleRegisterResult(self, returned, result): 1260 """Handle the registration result.""" 1261 gui = self._wizard.gui 1262 1263 gui.endBusy() 1264 1265 print "Registration result:" 1266 print " returned:", returned 1267 if returned: 1268 print " registered:", result.registered 1269 if result.registered: 1270 print " pilotID", result.pilotID 1271 print " loggedIn", result.loggedIn 1272 print " emailAlreadyRegistered:", result.emailAlreadyRegistered 1273 print " invalidData:", result.invalidData 1274 1275 registrationOK = returned and result.registered 1276 1277 message = xstr("register_ok") if registrationOK \ 1278 else xstr("register_failed") 1279 secondaryMessage = None 1280 if registrationOK: 1281 if result.loggedIn: 1282 secondaryMessage = xstr("register_info") % (result.pilotID,) 1283 else: 1284 secondaryMessage = xstr("register_nologin") % (result.pilotID,) 1285 messageType = MESSAGETYPE_INFO 1286 1287 config = gui.config 1288 config.pilotID = result.pilotID 1289 config.rememberPassword = self.rememberPassword 1290 if config.rememberPassword: 1291 config.password = self.password 1292 else: 1293 config.password = "" 1294 1295 config.save() 1296 elif returned and result.emailAlreadyRegistered: 1297 secondaryMessage = xstr("register_email_already") 1298 messageType = MESSAGETYPE_ERROR 1299 elif returned and result.invalidData: 1300 secondaryMessage = xstr("register_invalid_data") 1301 messageType = MESSAGETYPE_ERROR 1302 else: 1303 secondaryMessage = xstr("register_error") 1304 messageType = MESSAGETYPE_ERROR 1305 1306 dialog = gtk.MessageDialog(parent = gui.mainWindow, 1307 type = messageType, 1308 message_format = message) 1309 dialog.set_title(WINDOW_TITLE_BASE + " - " + 1310 xstr("register_result_title")) 1311 dialog.format_secondary_markup(secondaryMessage) 1312 1313 dialog.add_button(xstr("button_ok"), 0) 1314 1315 dialog.run() 1316 dialog.hide() 1317 1318 if registrationOK: 1319 if result.loggedIn: 1320 self._wizard.nextPage() 1321 else: 1322 self._wizard.jumpPage("login") 1185 1323 1186 1324 #-----------------------------------------------------------------------------
Note:
See TracChangeset
for help on using the changeset viewer.