Removed deprecated gender check in cz localflavor. Refs #14593.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@17939 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
Claude Paroz 2012-04-26 17:48:50 +00:00
parent be12c9e908
commit a6b2a15348
2 changed files with 4 additions and 44 deletions

View File

@ -50,7 +50,6 @@ class CZBirthNumberField(Field):
"""
default_error_messages = {
'invalid_format': _(u'Enter a birth number in the format XXXXXX/XXXX or XXXXXXXXXX.'),
'invalid_gender': _(u'Invalid optional parameter Gender, valid values are \'f\' and \'m\''),
'invalid': _(u'Enter a valid birth number.'),
}
@ -73,22 +72,10 @@ class CZBirthNumberField(Field):
# Birth number is in format YYMMDD. Females have month value raised by 50.
# In case that all possible number are already used (for given date),
# the month field is raised by 20.
if gender is not None:
import warnings
warnings.warn(
"Support for validating the gender of a CZ Birth number has been deprecated.",
DeprecationWarning)
if gender == 'f':
female_const = 50
elif gender == 'm':
female_const = 0
else:
raise ValidationError(self.error_messages['invalid_gender'])
month = int(birth[2:4]) - female_const
if (not 1 <= month <= 12):
if (not 1 <= (month - 20) <= 12):
raise ValidationError(self.error_messages['invalid'])
month = int(birth[2:4])
if (not 1 <= month <= 12) and (not 21 <= month <= 32) and \
(not 51 <= month <= 62) and (not 71 <= month <= 82):
raise ValidationError(self.error_messages['invalid'])
day = int(birth[4:6])
if not (1 <= day <= 31):

View File

@ -1,5 +1,3 @@
import warnings
from django.contrib.localflavor.cz.forms import (CZPostalCodeField,
CZRegionSelect, CZBirthNumberField, CZICNumberField)
@ -8,17 +6,6 @@ from django.test import SimpleTestCase
class CZLocalFlavorTests(SimpleTestCase):
def setUp(self):
self.save_warnings_state()
warnings.filterwarnings(
"ignore",
category=DeprecationWarning,
module='django.contrib.localflavor.cz.forms'
)
def tearDown(self):
self.restore_warnings_state()
def test_CZRegionSelect(self):
f = CZRegionSelect()
out = u'''<select name="regions">
@ -75,20 +62,6 @@ class CZLocalFlavorTests(SimpleTestCase):
}
self.assertFieldOutput(CZBirthNumberField, valid, invalid)
# These tests should go away in 1.4.
# http://code.djangoproject.com/ticket/14593
f = CZBirthNumberField()
self.assertEqual(f.clean('880523/1237', 'm'), '880523/1237'),
self.assertEqual(f.clean('885523/1231', 'f'), '885523/1231')
self.assertRaisesRegexp(ValidationError, unicode(error_invalid),
f.clean, '881523/0000', 'm')
self.assertRaisesRegexp(ValidationError, unicode(error_invalid),
f.clean, '885223/0000', 'm')
self.assertRaisesRegexp(ValidationError, unicode(error_invalid),
f.clean, '881523/0000', 'f')
self.assertRaisesRegexp(ValidationError, unicode(error_invalid),
f.clean, '885223/0000', 'f')
def test_CZICNumberField(self):
error_invalid = [u'Enter a valid IC number.']
valid ={