Exemplo n.º 1
0
 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(self):
     """Perform input validation."""
     correct_mail = is_correct_email(
                     compat.text_type(self.ui.email_edit.text()))
     correct_password = len(
                     compat.text_type(self.ui.password_edit.text())) > 0
     enabled = correct_mail and correct_password
     self.ui.sign_in_button.setEnabled(enabled)
 def _validate(self):
     """Perform input validation."""
     correct_mail = is_correct_email(
         compat.text_type(self.ui.email_edit.text()))
     correct_password = len(compat.text_type(
         self.ui.password_edit.text())) > 0
     enabled = correct_mail and correct_password
     self.ui.sign_in_button.setEnabled(enabled)
Exemplo n.º 6
0
 def email_assistance(self):
     """Show help for the email field."""
     text = compat.text_type(self.ui.email_edit.text())
     if not is_correct_email(text):
         self.set_error_message(self.ui.email_assistance, INVALID_EMAIL)
         common.check_as_invalid(self.ui.email_edit)
     else:
         self.ui.email_assistance.setVisible(False)
         common.check_as_valid(self.ui.email_edit)
 def email_assistance(self):
     """Show help for the email field."""
     text = compat.text_type(self.ui.email_edit.text())
     if not is_correct_email(text):
         self.set_error_message(self.ui.email_assistance, INVALID_EMAIL)
         common.check_as_invalid(self.ui.email_edit)
     else:
         self.ui.email_assistance.setVisible(False)
         common.check_as_valid(self.ui.email_edit)
Exemplo n.º 8
0
    def _validate_email(self, email1, email2=None):
        """Validate 'email1', return error message if not valid.

        If 'email2' is given, must match 'email1'.
        """
        if email2 is not None and email1 != email2:
            return EMAIL_MISMATCH

        if not email1:
            return FIELD_REQUIRED

        if not is_correct_email(email1):
            return EMAIL_INVALID
Exemplo n.º 9
0
    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(self):
     """Validate that we have an email."""
     email = compat.text_type(self.ui.email_line_edit.text())
     self.ui.send_button.setEnabled(is_correct_email(email))
 def _validate(self):
     """Validate that we have an email."""
     email = compat.text_type(self.ui.email_line_edit.text())
     self.ui.send_button.setEnabled(is_correct_email(email))