Commits

Anonymous committed 165bf15

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

  • Participants
  • Parent commits ab81460

Comments (0)

Files changed (2)

django/contrib/localflavor/cz/forms.py

     """
     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.'),
     }
 
         # 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):

tests/regressiontests/localflavor/cz/tests.py

-import warnings
-
 from django.contrib.localflavor.cz.forms import (CZPostalCodeField,
     CZRegionSelect, CZBirthNumberField, CZICNumberField)
 
 
 
 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">
         }
         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 ={