1
0
mirror of https://github.com/django/django.git synced 2025-11-07 07:15:35 +00:00

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
This commit is contained in:
Alex Gaynor
2010-12-18 20:32:54 +00:00
parent 8f012072af
commit d01cb6ed17
4 changed files with 138 additions and 167 deletions

View File

@@ -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(')','')