Exemplo n.º 1
0
    def _add_password_field(self, form_desc, required=True):
        """Add a password field to a form description.
        Arguments:
            form_desc: A form description
        Keyword Arguments:
            required (bool): Whether this field is required; defaults to True
        """
        # Translators: This label appears above a field on the registration form
        # meant to hold the user's password.
        password_label = _(u"Password")

        restrictions = {
            "min_length": password_min_length(),
            "max_length": password_max_length(),
        }

        complexities = password_complexity()
        for key, value in complexities.iteritems():
            api_key = key.lower().replace(' ', '_')
            restrictions[api_key] = value

        form_desc.add_field(
            "password",
            label=password_label,
            field_type="password",
            instructions=password_instructions(),
            restrictions=restrictions,
            required=required
        )
Exemplo n.º 2
0
    def _add_password_field(self, form_desc, required=True):
        """Add a password field to a form description.
        Arguments:
            form_desc: A form description
        Keyword Arguments:
            required (bool): Whether this field is required; defaults to True
        """
        # Translators: This label appears above a field on the registration form
        # meant to hold the user's password.
        password_label = _(u"Password")

        restrictions = {
            "min_length": password_min_length(),
            "max_length": password_max_length(),
        }

        complexities = password_complexity()
        for key, value in complexities.iteritems():
            api_key = key.lower().replace(' ', '_')
            restrictions[api_key] = value

        form_desc.add_field("password",
                            label=password_label,
                            field_type="password",
                            instructions=password_instructions(),
                            restrictions=restrictions,
                            required=required)
 def test_password_instruction(self, config, msg):
     """ Tests password_instruction """
     with override_settings(PASSWORD_COMPLEXITY=config):
         self.assertIn(msg, password_instructions())
 def test_password_instruction(self, config, msg):
     """ Tests password_instruction """
     with override_settings(PASSWORD_COMPLEXITY=config):
         self.assertIn(msg, password_instructions())