diff options
| author | Alex Gaynor <alex.gaynor@gmail.com> | 2010-12-18 20:32:54 +0000 |
|---|---|---|
| committer | Alex Gaynor <alex.gaynor@gmail.com> | 2010-12-18 20:32:54 +0000 |
| commit | d01cb6ed17647ed8af8b5c3d083fbd3ca21039df (patch) | |
| tree | 6b9b5b4a5054dcf7231bfe4f30f239c0ab5d28e2 /django | |
| parent | 8f012072afb2d4ec25cddab29cf0b9ef605bf138 (diff) | |
Fixed #14864, #14864 -- ROCIFField didn't accept values starting with RO, as it was supposed to, and ROCNPField, ROIBANField, and ROPhoneNumberField didn't handle all EMPTY_VALUES correctly. Also converted Romanian localflavor doctests to unittests. We have always been at war with doctests. Thanks to Idan Gazit.
Fixing RO localflavor clean() #14864
git-svn-id: http://code.djangoproject.com/svn/django/trunk@14951 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'django')
| -rw-r--r-- | django/contrib/localflavor/ro/forms.py | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/django/contrib/localflavor/ro/forms.py b/django/contrib/localflavor/ro/forms.py index dd86fce9f2..a218bfd167 100644 --- a/django/contrib/localflavor/ro/forms.py +++ b/django/contrib/localflavor/ro/forms.py @@ -20,7 +20,7 @@ class ROCIFField(RegexField): } def __init__(self, *args, **kwargs): - super(ROCIFField, self).__init__(r'^[0-9]{2,10}', max_length=10, + super(ROCIFField, self).__init__(r'^(RO)?[0-9]{2,10}', max_length=10, min_length=2, *args, **kwargs) def clean(self, value): @@ -65,6 +65,8 @@ class ROCNPField(RegexField): CNP validations """ value = super(ROCNPField, self).clean(value) + if value in EMPTY_VALUES: + return u'' # check birthdate digits import datetime try: @@ -150,6 +152,8 @@ class ROIBANField(RegexField): Strips - and spaces, performs country code and checksum validation """ value = super(ROIBANField, self).clean(value) + if value in EMPTY_VALUES: + return u'' value = value.replace('-','') value = value.replace(' ','') value = value.upper() @@ -180,6 +184,8 @@ class ROPhoneNumberField(RegexField): Strips -, (, ) and spaces. Checks the final length. """ value = super(ROPhoneNumberField, self).clean(value) + if value in EMPTY_VALUES: + return u'' value = value.replace('-','') value = value.replace('(','') value = value.replace(')','') |
