Merge "[DynamicUI] Apply user regex for the password field"

This commit is contained in:
Jenkins 2016-02-02 12:07:31 +00:00 committed by Gerrit Code Review
commit 81bc5bbab4
4 changed files with 46 additions and 24 deletions

View File

@ -238,27 +238,42 @@ class PasswordField(CharField):
def __init__(self, label, *args, **kwargs):
self.confirm_input = kwargs.pop('confirm_input', True)
kwargs.update({'label': label,
'error_messages': kwargs.get('error_messages', {}),
'widget': forms.PasswordInput(render_value=True)})
validators = kwargs.get('validators')
help_text = kwargs.get('help_text')
if not help_text:
help_text = _('Enter a complex password with at least one letter, \
one number and one special character')
error_messages = {
'invalid': self.validate_password.message}
err_msg = kwargs.get('error_messages')
if err_msg:
if err_msg.get('required'):
error_messages['required'] = err_msg.get('required')
if not validators:
# Apply default validator if it is not provided
validators = [self.validate_password]
if not help_text:
help_text = _('Enter a complex password with at least one \
letter, one number and one special character')
kwargs.update({
'min_length': 7,
'max_length': 255,
'validators': [self.validate_password],
'label': label,
'error_messages': error_messages,
'help_text': help_text,
'widget': self.PasswordInput(render_value=True),
})
kwargs['error_messages'].setdefault(
'invalid', self.validate_password.message)
kwargs['min_length'] = kwargs.get('min_length', 7)
kwargs['max_length'] = kwargs.get('max_length', 255)
kwargs['widget'] = self.PasswordInput(render_value=True)
else:
if not help_text:
help_text = _('Enter a password for the application')
requirements = []
for v in validators:
if not isinstance(v, django_validator.RegexValidator):
requirements.append(v['message'])
if requirements:
help_text = (help_text +
_(' with the following requirements:\n*') +
'\n*'.join(requirements))
kwargs.update({'validators': validators,
'help_text': help_text})
super(PasswordField, self).__init__(*args, **kwargs)

View File

@ -14,7 +14,7 @@
import semantic_version
LATEST_FORMAT_VERSION = '2.2'
LATEST_FORMAT_VERSION = '2.3'
def check_version(version):

View File

@ -0,0 +1,15 @@
---
features:
- Version of Dynamic UI is increased to 2.3 due to *password* field update.
Now *password* supports validator overloading and control of automatic
password conformation field insertion.
* If ``regexpValidator`` is provided, default complex check for numbers,
capital and small letters in the password is not performed. Also, several
validators with corresponding Dynamic UI field may be used.
* ``confirmInput`` parameter is supported now for controlling whether
password field should be cloned or not.
If application author decided to turn off automatic field cloning, he
should set the new parameter to *false*.

View File

@ -1,8 +0,0 @@
---
features:
- Dynamic UI field of type *password* supports ``confirmInput`` parameter
now. It controls whethere password field should be cloned or not.
If application author decided to turn off automatic field cloning, he
should set the new parameter to *false*.