def validate_form(self): """Validate the info of the form and return an error.""" logger.debug('SetUpAccountPage.validate_form') name = compat.text_type(self.ui.name_edit.text()).strip() email = compat.text_type(self.ui.email_edit.text()) confirm_email = compat.text_type(self.ui.confirm_email_edit.text()) password = compat.text_type(self.ui.password_edit.text()) confirm_password = compat.text_type( self.ui.confirm_password_edit.text()) captcha_solution = compat.text_type( self.ui.captcha_solution_edit.text()) condition = True messages = [] if not name: condition = False self.set_error_message(self.ui.name_assistance, NAME_INVALID) if not is_correct_email(email): condition = False self.set_error_message(self.ui.email_assistance, EMAIL_INVALID) if email != confirm_email: condition = False self.set_error_message(self.ui.confirm_email_assistance, EMAIL_MISMATCH) if not is_min_required_password(password): messages.append(PASSWORD_TOO_WEAK) if password != confirm_password: messages.append(PASSWORD_MISMATCH) if not captcha_solution: messages.append(CAPTCHA_REQUIRED_ERROR) if len(messages) > 0: condition = False self.show_error('\n'.join(messages)) return condition
def validate_form(self): """Validate the info of the form and return an error.""" logger.debug("SetUpAccountPage.validate_form") name = compat.text_type(self.ui.name_edit.text()).strip() email = compat.text_type(self.ui.email_edit.text()) confirm_email = compat.text_type(self.ui.confirm_email_edit.text()) password = compat.text_type(self.ui.password_edit.text()) confirm_password = compat.text_type(self.ui.confirm_password_edit.text()) captcha_solution = compat.text_type(self.ui.captcha_solution_edit.text()) condition = True messages = [] if not name: condition = False self.set_error_message(self.ui.name_assistance, NAME_INVALID) if not is_correct_email(email): condition = False self.set_error_message(self.ui.email_assistance, EMAIL_INVALID) if email != confirm_email: condition = False self.set_error_message(self.ui.confirm_email_assistance, EMAIL_MISMATCH) if not is_min_required_password(password): messages.append(PASSWORD_TOO_WEAK) if password != confirm_password: messages.append(PASSWORD_MISMATCH) if not captcha_solution: messages.append(CAPTCHA_REQUIRED_ERROR) if len(messages) > 0: condition = False self.show_error("\n".join(messages)) return condition
def _enable_setup_button(self): """Only enable the setup button if the form is valid.""" name = compat.text_type(self.ui.name_edit.text()).strip() email = compat.text_type(self.ui.email_edit.text()) confirm_email = compat.text_type(self.ui.confirm_email_edit.text()) password = compat.text_type(self.ui.password_edit.text()) confirm_password = compat.text_type(self.ui.confirm_password_edit.text()) captcha_solution = compat.text_type(self.ui.captcha_solution_edit.text()) # Check for len(name) > 0 to ensure that a bool is assigned to enabled if not self.terms_checkbox.isVisible(): checkbox_terms = True else: checkbox_terms = self.terms_checkbox.isChecked() enabled = ( checkbox_terms and len(captcha_solution) > 0 and is_min_required_password(password) and password == confirm_password and is_correct_email(email) and email == confirm_email and len(name) > 0 ) self.set_up_button.setEnabled(enabled)
def _validate_password(self, password1, password2=None): """Validate 'password1', return error message if not valid. If 'password2' is given, must match 'email1'. """ if password2 is not None and password1 != password2: return PASSWORD_MISMATCH if not is_min_required_password(password1): return PASSWORD_TOO_WEAK
def _validate(self): """Enable the submit button if data is valid.""" enabled = True code = compat.text_type(self.ui.reset_code_line_edit.text()) password = compat.text_type(self.ui.password_line_edit.text()) confirm_password = compat.text_type( self.ui.confirm_password_line_edit.text()) if not is_min_required_password(password): enabled = False elif not self.is_correct_password_confirmation(confirm_password): enabled = False elif not code: enabled = False self.ui.reset_password_button.setEnabled(enabled)
def _enable_setup_button(self): """Only enable the setup button if the form is valid.""" name = compat.text_type(self.ui.name_edit.text()).strip() email = compat.text_type(self.ui.email_edit.text()) confirm_email = compat.text_type(self.ui.confirm_email_edit.text()) password = compat.text_type(self.ui.password_edit.text()) confirm_password = compat.text_type( self.ui.confirm_password_edit.text()) captcha_solution = compat.text_type( self.ui.captcha_solution_edit.text()) # Check for len(name) > 0 to ensure that a bool is assigned to enabled if not self.terms_checkbox.isVisible(): checkbox_terms = True else: checkbox_terms = self.terms_checkbox.isChecked() enabled = checkbox_terms and \ len(captcha_solution) > 0 and \ is_min_required_password(password) and \ password == confirm_password and is_correct_email(email) and \ email == confirm_email and len(name) > 0 self.set_up_button.setEnabled(enabled)