mirror of
https://github.com/django/django.git
synced 2025-11-07 07:15:35 +00:00
Fixed #14860 -- PLPESELField, PLNIPField, and PLREGONField didn't handle all EMPTY_VALUES correctly. Also converted teh Polish localflavor doctests into unittests. We have always been at war with doctests. Thanks to Idan Gazit.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@14949 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
@@ -7,6 +7,7 @@ import re
|
||||
from django.forms import ValidationError
|
||||
from django.forms.fields import Select, RegexField
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
from django.core.validators import EMPTY_VALUES
|
||||
|
||||
class PLProvinceSelect(Select):
|
||||
"""
|
||||
@@ -45,6 +46,8 @@ class PLPESELField(RegexField):
|
||||
|
||||
def clean(self,value):
|
||||
super(PLPESELField, self).clean(value)
|
||||
if value in EMPTY_VALUES:
|
||||
return u''
|
||||
if not self.has_valid_checksum(value):
|
||||
raise ValidationError(self.error_messages['checksum'])
|
||||
return u'%s' % value
|
||||
@@ -78,6 +81,8 @@ class PLNIPField(RegexField):
|
||||
|
||||
def clean(self,value):
|
||||
super(PLNIPField, self).clean(value)
|
||||
if value in EMPTY_VALUES:
|
||||
return u''
|
||||
value = re.sub("[-]", "", value)
|
||||
if not self.has_valid_checksum(value):
|
||||
raise ValidationError(self.error_messages['checksum'])
|
||||
@@ -116,6 +121,8 @@ class PLREGONField(RegexField):
|
||||
|
||||
def clean(self,value):
|
||||
super(PLREGONField, self).clean(value)
|
||||
if value in EMPTY_VALUES:
|
||||
return u''
|
||||
if not self.has_valid_checksum(value):
|
||||
raise ValidationError(self.error_messages['checksum'])
|
||||
return u'%s' % value
|
||||
|
||||
Reference in New Issue
Block a user