diff -r 6641e941ef1e -r ff1a9aa48cfd app/django/contrib/localflavor/pl/forms.py --- a/app/django/contrib/localflavor/pl/forms.py Tue Oct 14 12:36:55 2008 +0000 +++ b/app/django/contrib/localflavor/pl/forms.py Tue Oct 14 16:00:59 2008 +0000 @@ -4,28 +4,27 @@ import re -from django.newforms import ValidationError -from django.newforms.fields import Select, RegexField -from django.utils.translation import ugettext as _ +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 PLCountySelect(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(PLCountySelect, 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 @@ } 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 @@ 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 @@ } 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 @@ 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 @@ } 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