Author: claudep
Date: 2012-04-26 10:48:50 -0700 (Thu, 26 Apr 2012)
New Revision: 17939
Modified:
django/trunk/django/contrib/localflavor/cz/forms.py
django/trunk/tests/regressiontests/localflavor/cz/tests.py
Log:
Removed deprecated gender check in cz localflavor. Refs #14593.
Modified: django/trunk/django/contrib/localflavor/cz/forms.py
===================================================================
--- django/trunk/django/contrib/localflavor/cz/forms.py 2012-04-26 17:15:40 UTC
(rev 17938)
+++ django/trunk/django/contrib/localflavor/cz/forms.py 2012-04-26 17:48:50 UTC
(rev 17939)
@@ -50,7 +50,6 @@
"""
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,23 +72,11 @@
# 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])
+ 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'])
- month = int(birth[2:4]) - female_const
- if (not 1 <= month <= 12):
- if (not 1 <= (month - 20) <= 12):
- raise ValidationError(self.error_messages['invalid'])
-
day = int(birth[4:6])
if not (1 <= day <= 31):
raise ValidationError(self.error_messages['invalid'])
Modified: django/trunk/tests/regressiontests/localflavor/cz/tests.py
===================================================================
--- django/trunk/tests/regressiontests/localflavor/cz/tests.py 2012-04-26
17:15:40 UTC (rev 17938)
+++ django/trunk/tests/regressiontests/localflavor/cz/tests.py 2012-04-26
17:48:50 UTC (rev 17939)
@@ -1,5 +1,3 @@
-import warnings
-
from django.contrib.localflavor.cz.forms import (CZPostalCodeField,
CZRegionSelect, CZBirthNumberField, CZICNumberField)
@@ -8,17 +6,6 @@
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 @@
}
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 ={
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/django-updates?hl=en.