diff --git a/django/contrib/localflavor/pl/forms.py b/django/contrib/localflavor/pl/forms.py
index 8410c72a3c..5532eb803b 100644
--- a/django/contrib/localflavor/pl/forms.py
+++ b/django/contrib/localflavor/pl/forms.py
@@ -8,24 +8,23 @@ from django.forms import ValidationError
from django.forms.fields import Select, RegexField
from django.utils.translation import ugettext_lazy as _
-class PLVoivodeshipSelect(Select):
+class PLProvinceSelect(Select):
"""
- A select widget with list of Polish voivodeships (administrative provinces)
- as choices.
+ A select widget with list of Polish administrative provinces as choices.
"""
def __init__(self, attrs=None):
from pl_voivodeships import VOIVODESHIP_CHOICES
- super(PLVoivodeshipSelect, self).__init__(attrs, choices=VOIVODESHIP_CHOICES)
+ super(PLProvinceSelect, self).__init__(attrs, choices=VOIVODESHIP_CHOICES)
-class PLAdministrativeUnitSelect(Select):
+class PLCountiesSelect(Select):
"""
A select widget with list of Polish administrative units as choices.
"""
def __init__(self, attrs=None):
from pl_administrativeunits import ADMINISTRATIVE_UNIT_CHOICES
- super(PLAdministrativeUnitSelect, self).__init__(attrs, choices=ADMINISTRATIVE_UNIT_CHOICES)
+ super(PLCountiesSelect, self).__init__(attrs, choices=ADMINISTRATIVE_UNIT_CHOICES)
-class PLNationalIdentificationNumberField(RegexField):
+class PLPESELField(RegexField):
"""
A form field that validates as Polish Identification Number (PESEL).
@@ -41,11 +40,11 @@ class PLNationalIdentificationNumberField(RegexField):
}
def __init__(self, *args, **kwargs):
- super(PLNationalIdentificationNumberField, self).__init__(r'^\d{11}$',
+ super(PLPESELField, self).__init__(r'^\d{11}$',
max_length=None, min_length=None, *args, **kwargs)
def clean(self,value):
- super(PLNationalIdentificationNumberField, self).clean(value)
+ super(PLPESELField, self).clean(value)
if not self.has_valid_checksum(value):
raise ValidationError(self.error_messages['checksum'])
return u'%s' % value
@@ -60,7 +59,7 @@ class PLNationalIdentificationNumberField(RegexField):
result += int(number[i]) * multiple_table[i]
return result % 10 == 0
-class PLTaxNumberField(RegexField):
+class PLNIPField(RegexField):
"""
A form field that validates as Polish Tax Number (NIP).
Valid forms are: XXX-XXX-YY-YY or XX-XX-YYY-YYY.
@@ -74,11 +73,11 @@ class PLTaxNumberField(RegexField):
}
def __init__(self, *args, **kwargs):
- super(PLTaxNumberField, self).__init__(r'^\d{3}-\d{3}-\d{2}-\d{2}$|^\d{2}-\d{2}-\d{3}-\d{3}$',
+ super(PLNIPField, self).__init__(r'^\d{3}-\d{3}-\d{2}-\d{2}$|^\d{2}-\d{2}-\d{3}-\d{3}$',
max_length=None, min_length=None, *args, **kwargs)
def clean(self,value):
- super(PLTaxNumberField, self).clean(value)
+ super(PLNIPField, self).clean(value)
value = re.sub("[-]", "", value)
if not self.has_valid_checksum(value):
raise ValidationError(self.error_messages['checksum'])
@@ -99,10 +98,10 @@ class PLTaxNumberField(RegexField):
else:
return False
-class PLNationalBusinessRegisterField(RegexField):
+class PLREGONField(RegexField):
"""
- A form field that validated as Polish National Official Business Register Number (REGON)
- Valid forms are: 7 or 9 digits number
+ A form field that validated as Polish National Official Business Register
+ Number (REGON). Valid numbers contain 7 or 9 digits.
More on the field: http://www.stat.gov.pl/bip/regon_ENG_HTML.htm
@@ -114,11 +113,11 @@ class PLNationalBusinessRegisterField(RegexField):
}
def __init__(self, *args, **kwargs):
- super(PLNationalBusinessRegisterField, self).__init__(r'^\d{7,9}$',
+ super(PLREGONField, self).__init__(r'^\d{7,9}$',
max_length=None, min_length=None, *args, **kwargs)
def clean(self,value):
- super(PLNationalBusinessRegisterField, self).clean(value)
+ super(PLREGONField, self).clean(value)
if not self.has_valid_checksum(value):
raise ValidationError(self.error_messages['checksum'])
return u'%s' % value
diff --git a/tests/regressiontests/forms/localflavor/pl.py b/tests/regressiontests/forms/localflavor/pl.py
index becdda8a1d..89679644db 100644
--- a/tests/regressiontests/forms/localflavor/pl.py
+++ b/tests/regressiontests/forms/localflavor/pl.py
@@ -2,17 +2,17 @@
# Tests for the contrib/localflavor/ PL form fields.
tests = r"""
-# PLVoivodeshipSelect ##########################################################
+# PLProvinceSelect ##########################################################
->>> from django.contrib.localflavor.pl.forms import PLVoivodeshipSelect
->>> f = PLVoivodeshipSelect()
+>>> from django.contrib.localflavor.pl.forms import PLProvinceSelect
+>>> f = PLProvinceSelect()
>>> f.render('voivodeships','pomerania')
u''
-# PLAdministrativeUnitSelect ##########################################################
+# PLCountiesSelect ##########################################################
->>> from django.contrib.localflavor.pl.forms import PLAdministrativeUnitSelect
->>> f = PLAdministrativeUnitSelect()
+>>> from django.contrib.localflavor.pl.forms import PLCountiesSelect
+>>> f = PLCountiesSelect()
>>> f.render('administrativeunit','katowice')
u''
@@ -27,10 +27,10 @@ ValidationError: [u'Enter a postal code in the format XX-XXX.']
>>> f.clean('41-403')
u'41-403'
-# PLTaxNumberField ###############################################################
+# PLNIPField ###############################################################
->>> from django.contrib.localflavor.pl.forms import PLTaxNumberField
->>> f = PLTaxNumberField()
+>>> from django.contrib.localflavor.pl.forms import PLNIPField
+>>> f = PLNIPField()
>>> f.clean('43-343-234-323')
Traceback (most recent call last):
...
@@ -44,10 +44,10 @@ Traceback (most recent call last):
...
ValidationError: [u'Wrong checksum for the Tax Number (NIP).']
-# PLNationalIdentificationNumberField ############################################
+# PLPESELField ############################################
->>> from django.contrib.localflavor.pl.forms import PLNationalIdentificationNumberField
->>> f = PLNationalIdentificationNumberField()
+>>> from django.contrib.localflavor.pl.forms import PLPESELField
+>>> f = PLPESELField()
>>> f.clean('80071610614')
u'80071610614'
>>> f.clean('80071610610')
@@ -63,10 +63,10 @@ Traceback (most recent call last):
...
ValidationError: [u'National Identification Number consists of 11 digits.']
-# PLNationalBusinessRegisterField ################################################
+# PLREGONField ################################################
->>> from django.contrib.localflavor.pl.forms import PLNationalBusinessRegisterField
->>> f = PLNationalBusinessRegisterField()
+>>> from django.contrib.localflavor.pl.forms import PLREGONField
+>>> f = PLREGONField()
>>> f.clean('590096454')
u'590096454'
>>> f.clean('590096453')