Fixed #8276 -- Changed the names of a few Polish localflavor classes to match
their common names/acronyms, similar to other localflavors. Backwards incompatible if you're using these classes. git-svn-id: http://code.djangoproject.com/svn/django/trunk@8345 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
parent
9d83444f16
commit
4adf048a51
|
@ -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
|
||||
|
|
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue